2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-15 17:38:05 +00:00
* e107 website system
*
2013-02-27 15:18:48 +01:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2009-11-15 17:38:05 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2010-06-23 10:21:21 +00:00
*/
2006-12-02 04:36:16 +00:00
2012-01-11 14:54:47 +00:00
if ( ! defined ( 'e107_INIT' )) { exit ; }
/**
*
* @ package e107
* @ category e107_handlers
* @ author e107inc
*
* Plugin administration handler
*/
2006-12-02 04:36:16 +00:00
2013-02-27 15:18:48 +01:00
2012-01-11 14:54:47 +00:00
e107 :: coreLan ( 'plugin' , true );
2009-09-03 22:27:32 +00:00
2017-02-03 20:18:45 -08:00
// new in v2.1.5 - optimized for speed.
2022-04-04 10:54:24 -07:00
/**
*
*/
2017-02-03 20:18:45 -08:00
class e_plugin
{
protected $_data = array ();
protected $_ids = array ();
protected $_installed = array ();
protected $_addons = array ();
2017-02-04 12:49:44 -08:00
protected $_plugdir = null ; // the currently loaded plugin
2017-02-03 20:18:45 -08:00
const CACHETIME = 120 ; // 2 hours
const CACHETAG = " Meta_plugin " ;
2017-02-08 17:37:24 -08:00
protected $_addon_types = array (
'e_admin' ,
'e_bb' ,
'e_cron' ,
'e_notify' ,
'e_linkgen' ,
'e_list' ,
2021-03-17 11:22:25 -07:00
'e_meta' , // @deprecated
'e_emailprint' , /* @deprecated - see e_print */
2019-03-11 16:30:01 -07:00
'e_print' , // new v2.2
2017-02-08 17:37:24 -08:00
'e_frontpage' ,
'e_latest' , /* @deprecated - see e_dashboard */
'e_status' , /* @deprecated - see e_dashboard */
'e_menu' ,
'e_search' ,
'e_shortcode' ,
'e_module' ,
'e_event' ,
'e_comment' ,
'e_sql' ,
'e_dashboard' , // Admin Front-Page addon.
// 'e_userprofile', @deprecated @see e_user
'e_header' , // loaded in header prior to javascript manager.
'e_footer' , // Loaded in footer prior to javascript manager.
// 'e_userinfo', @deprecated @see e_user
'e_tagwords' ,
'e_url' , // simple mod-rewrite.
'e_mailout' ,
'e_sitelink' , // sitelinks generator.
'e_tohtml' , /* @deprecated - use e_parse */
'e_featurebox' ,
'e_parse' ,
2021-03-17 11:22:25 -07:00
'e_print' , // new v2.3.1
2017-02-08 17:37:24 -08:00
'e_related' ,
'e_rss' ,
'e_upload' ,
'e_user' ,
'e_library' , // For third-party libraries are defined by plugins/themes.
2018-01-29 12:03:15 -08:00
'e_gsitemap' ,
2018-06-12 18:09:00 +02:00
'e_output' , //hook into all pages at the end (after closing </html>)
2017-02-08 17:37:24 -08:00
);
2018-08-05 11:40:21 -07:00
protected $_core_plugins = array (
" _blank " , " admin_menu " , " banner " , " blogcalendar_menu " ,
2021-01-25 07:57:24 -08:00
" chatbox_menu " , " comment_menu " ,
2018-08-05 11:40:21 -07:00
" contact " , " download " , " featurebox " , " forum " , " gallery " ,
2021-01-24 06:47:04 -08:00
" gsitemap " , " hero " , " import " , " linkwords " , " list_new " , " login_menu " ,
2021-01-21 09:38:38 -08:00
" newforumposts_main " , " news " , " newsfeed " ,
2018-08-05 11:40:21 -07:00
" newsletter " , " online " , " page " , " pm " , " poll " ,
" rss_menu " , " search_menu " , " siteinfo " , " social " , " tagcloud " , " tinymce4 " ,
2020-12-29 10:30:05 -08:00
" user "
2018-08-05 11:40:21 -07:00
);
2017-02-08 17:37:24 -08:00
2019-06-16 12:33:28 -07:00
private $_accepted_categories = array ( 'settings' => EPL_ADLAN_147 , 'users' => EPL_ADLAN_148 , 'content' => EPL_ADLAN_149 , 'tools' => EPL_ADLAN_150 , 'manage' => EPL_ADLAN_151 , 'misc' => EPL_ADLAN_152 , 'menu' => EPL_ADLAN_153 , 'about' => EPL_ADLAN_154 );
2017-02-03 20:18:45 -08:00
function __construct ()
{
2017-02-08 17:37:24 -08:00
$this -> _init ();
2017-02-03 20:18:45 -08:00
2020-05-05 15:11:49 -07:00
if ( empty ( $this -> _ids ) )
2017-02-03 20:18:45 -08:00
{
2019-01-13 14:08:46 -08:00
// e107::getDebug()->log("Running e_plugin::_initIDs()");
// e107::getDebug()->log(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
2017-02-08 17:37:24 -08:00
$this -> _initIDs ();
2017-02-03 20:18:45 -08:00
}
}
2017-02-08 17:37:24 -08:00
/**
2017-02-04 12:49:44 -08:00
* Load specified plugin data .
* @ param string $plugdir
* @ return e_plugin
*/
public function load ( $plugdir )
{
$this -> _plugdir = ( string ) $plugdir ;
return $this ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2017-02-04 15:52:26 -08:00
public function getCategoryList ()
{
return $this -> _accepted_categories ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return int [] | string []
*/
2017-02-08 17:37:24 -08:00
public function getDetected ()
{
return array_keys ( $this -> _data );
}
2022-04-04 10:54:24 -07:00
/**
* @ return string []
*/
2018-08-05 11:40:21 -07:00
public function getCorePluginList ()
{
return $this -> _core_plugins ;
}
2017-02-04 12:49:44 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ return $this
*/
2017-02-03 20:18:45 -08:00
public function clearCache ()
{
2018-08-05 15:08:54 -07:00
$this -> _installed = array ();
$this -> _addons = array ();
2020-01-13 00:21:59 +01:00
e107 :: setRegistry ( 'core/e107/addons/e_url' );
2018-08-05 15:08:54 -07:00
2017-02-08 17:37:24 -08:00
$this -> _init ( true );
$this -> _initIDs ();
2017-02-05 15:49:03 -08:00
return $this ;
2017-02-03 20:18:45 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return array | false [] | string []
*/
2018-07-29 15:11:40 +02:00
public function getInstalledWysiwygEditors ()
{
$result = array ();
2018-07-30 22:17:03 +02:00
foreach ( array_keys ( $this -> _installed ) as $k )
2018-07-29 15:11:40 +02:00
{
$pl = new e_plugin ();
$pl -> load ( $k );
$keys = $pl -> getKeywords ();
2018-07-30 22:17:03 +02:00
// check the keywords
if ( is_array ( $keys ) && in_array ( 'wysiwyg' , $keys [ 'word' ]))
2018-07-29 15:11:40 +02:00
{
2018-07-30 22:17:03 +02:00
if ( in_array ( 'default' , $keys [ 'word' ]))
2018-07-29 15:11:40 +02:00
{
2018-07-30 22:17:03 +02:00
// add "default" editor to the beginning of the array
$result = array_merge ( array ( $k => $pl -> getName ()), $result );
}
else
{
// add all "wysiwyg" editors to the array
$result [ $k ] = $pl -> getName ();
2018-07-29 15:11:40 +02:00
}
}
}
return $result ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2017-02-03 20:18:45 -08:00
public function getInstalled ()
{
return $this -> _installed ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-04 12:49:44 -08:00
public function getId ()
2017-02-03 20:18:45 -08:00
{
2017-11-07 17:52:15 -08:00
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
}
2017-02-04 12:49:44 -08:00
if ( isset ( $this -> _ids [ $this -> _plugdir ]))
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
return $this -> _ids [ $this -> _plugdir ];
2017-02-03 20:18:45 -08:00
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-05 15:49:03 -08:00
public function getCompat ()
{
if ( isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'compatibility' ]))
{
return $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'compatibility' ];
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return bool
*/
2017-02-05 15:49:03 -08:00
public function getInstallRequired ()
{
2017-11-07 17:52:15 -08:00
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
}
2017-02-05 15:49:03 -08:00
if ( isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'installRequired' ]))
{
2021-01-24 17:00:02 -08:00
return $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'installRequired' ] !== 'false' ;
2017-02-05 15:49:03 -08:00
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-05 15:49:03 -08:00
public function getVersion ()
{
2017-11-07 17:52:15 -08:00
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
}
2017-02-05 15:49:03 -08:00
if ( isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'version' ]))
{
return $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'version' ];
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-04 15:52:26 -08:00
public function getDate ()
{
if ( isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'date' ]))
{
return $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'date' ];
}
return false ;
}
2017-02-06 08:47:39 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $type
* @ return false | mixed
*/
2017-02-05 15:49:03 -08:00
public function getAuthor ( $type = 'name' )
2017-02-04 15:52:26 -08:00
{
2017-02-05 15:49:03 -08:00
if ( ! isset ( $this -> _data [ $this -> _plugdir ][ 'author' ][ '@attributes' ][ $type ]))
2017-02-04 15:52:26 -08:00
{
return false ;
}
2017-02-05 15:49:03 -08:00
return $this -> _data [ $this -> _plugdir ][ 'author' ][ '@attributes' ][ $type ];
2017-02-04 15:52:26 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | string
*/
2017-02-04 12:49:44 -08:00
public function getCategory ()
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
if ( ! isset ( $this -> _data [ $this -> _plugdir ][ 'category' ]))
2017-02-03 20:18:45 -08:00
{
return false ;
}
2017-02-04 15:52:26 -08:00
return ( string ) $this -> _data [ $this -> _plugdir ][ 'category' ];
2017-02-03 20:18:45 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2018-07-29 15:11:40 +02:00
public function getKeywords ()
{
if ( ! isset ( $this -> _data [ $this -> _plugdir ][ 'keywords' ]))
{
return false ;
}
return $this -> _data [ $this -> _plugdir ][ 'keywords' ];
}
2017-02-03 20:18:45 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-04 12:49:44 -08:00
public function getDescription ()
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
if ( ! isset ( $this -> _data [ $this -> _plugdir ][ 'description' ][ '@value' ]))
2017-02-03 20:18:45 -08:00
{
return false ;
}
2017-02-04 12:49:44 -08:00
return $this -> _data [ $this -> _plugdir ][ 'description' ][ '@value' ];
2017-02-03 20:18:45 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $size
* @ param $opt
* @ return mixed | string | null
*/
public function getIcon ( $size = 16 , $opt = '' )
2017-02-03 20:18:45 -08:00
{
2021-02-03 05:22:28 -08:00
if ( ! isset ( $this -> _data [ $this -> _plugdir ]))
{
return null ;
}
2017-02-03 20:18:45 -08:00
2021-02-03 05:22:28 -08:00
$link = varset ( $this -> _data [ $this -> _plugdir ][ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ]);
2017-02-03 20:18:45 -08:00
2018-01-09 11:21:16 -08:00
$k = array ( 16 => 'iconSmall' , 24 => 'icon' , 32 => 'icon' , 128 => 'icon128' );
$def = array ( 16 => E_16_PLUGIN , 24 => E_24_PLUGIN , 32 => E_32_PLUGIN );
2017-02-03 20:18:45 -08:00
$key = $k [ $size ];
if ( empty ( $link [ $key ]))
{
return $def [ $size ];
}
2017-02-04 12:49:44 -08:00
$caption = $this -> getName ();
2017-02-03 20:18:45 -08:00
2017-02-04 15:52:26 -08:00
if ( $opt === 'path' )
{
return e107 :: getParser () -> createConstants ( e_PLUGIN_ABS . $this -> _plugdir . '/' . $link [ $key ]);
}
2017-02-05 15:49:03 -08:00
return " <img src=' " . e_PLUGIN . $this -> _plugdir . '/' . $link [ $key ] . " ' alt= \" " . $caption . " \" class='icon S " . $size . " ' /> " ;
2017-02-03 20:18:45 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return array | false | string | string []
*/
2017-02-04 12:49:44 -08:00
public function getAdminCaption ()
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
$att = $this -> _data [ $this -> _plugdir ][ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ];
2017-02-03 20:18:45 -08:00
if ( empty ( $att [ 'description' ]))
{
return false ;
}
return str_replace ( " ' " , '' , e107 :: getParser () -> toHTML ( $att [ 'description' ], FALSE , 'defs, emotes_off' ));
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | string
*/
2017-02-04 12:49:44 -08:00
public function getAdminUrl ()
2017-02-03 20:18:45 -08:00
{
2017-02-05 15:49:03 -08:00
if ( ! empty ( $this -> _data [ $this -> _plugdir ][ 'administration' ][ 'configFile' ]))
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
return e_PLUGIN_ABS . $this -> _plugdir . '/' . $this -> _data [ $this -> _plugdir ][ 'administration' ][ 'configFile' ];
2017-02-03 20:18:45 -08:00
}
return false ;
}
2017-02-06 08:47:39 -08:00
/**
* Check if the current plugin is a legacy plugin which doesn ' t use plugin . xml
* @ return mixed
*/
public function isLegacy ()
{
2017-11-07 17:52:15 -08:00
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
}
2021-01-22 06:32:59 -08:00
return varset ( $this -> _data [ $this -> _plugdir ][ 'legacy' ]);
2017-02-06 08:47:39 -08:00
}
2019-01-13 13:30:58 -08:00
/**
* Check if the current plugin has a global lan file
* @ return mixed
*/
public function hasLanGlobal ()
{
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
return null ;
}
return isset ( $this -> _data [ $this -> _plugdir ][ 'lan' ]) ? $this -> _data [ $this -> _plugdir ][ 'lan' ] : false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $plug
* @ param $version
* @ return $this
*/
function setInstalled ( $plug , $version )
2018-08-05 15:08:54 -07:00
{
$this -> _installed [ $plug ] = $version ;
return $this ;
}
2019-02-20 13:31:42 -08:00
2017-12-16 11:31:47 -08:00
/**
* Check if the currently loaded plugin is installed
2022-04-04 10:54:24 -07:00
* @ return bool
2017-12-16 11:31:47 -08:00
*/
public function isInstalled ()
{
if ( empty ( $this -> _plugdir ))
{
e107 :: getDebug () -> log ( " \$ this->_plugdir is empty " . __FILE__ . " " . __CLASS__ . " :: " . __METHOD__ );
}
2020-12-10 15:52:48 -08:00
return array_key_exists ( $this -> _plugdir , $this -> _installed );
2017-12-16 11:31:47 -08:00
}
/**
* Check if the currently loaded plugin ' s addon has errors .
2018-08-05 15:08:54 -07:00
* @ param string e_xxxx addon
2022-04-04 10:54:24 -07:00
* @ return int | array
2017-12-16 11:31:47 -08:00
*/
public function getAddonErrors ( $e_xxx )
{
2018-08-05 11:40:21 -07:00
if ( substr ( $e_xxx , - 3 ) === '.sc' )
{
$filename = $e_xxx ;
$sc = true ;
}
else
{
$filename = $e_xxx . " .php " ;
$sc = false ;
}
if ( is_readable ( e_PLUGIN . $this -> _plugdir . " / " . $filename ))
2017-12-16 11:31:47 -08:00
{
2018-08-05 11:40:21 -07:00
$content = file_get_contents ( e_PLUGIN . $this -> _plugdir . " / " . $filename );
2017-12-16 11:31:47 -08:00
}
else
{
return 2 ;
}
if ( substr ( $e_xxx , - 4 , 4 ) == '_sql' )
{
if ( strpos ( $content , 'INSERT INTO' ) !== false )
{
return array ( 'type' => 'error' , 'msg' => " INSERT sql commands are not permitted here. Use a " . $this -> _plugdir . " _setup.php file instead. " );
}
else
{
return 0 ;
}
}
// Generic markup check
2020-04-24 11:58:51 -07:00
if ( $sc === false && ! $this -> isValidAddonMarkup ( $content ))
2017-12-16 11:31:47 -08:00
{
return 1 ;
}
if ( $e_xxx == 'e_meta' && strpos ( $content , '<script' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Contains script tags. Use e_header.php with the e107::js() function instead. " );
}
if ( $e_xxx == 'e_latest' && strpos ( $content , '<div' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Using deprecated method. See e_latest.php in the forum plugin for an example. " );
}
if ( $e_xxx == 'e_status' && strpos ( $content , '<div' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Using deprecated method. See e_status.php in the forum plugin for an example. " );
}
return 0 ;
2020-04-24 11:58:51 -07:00
}
2017-12-16 11:31:47 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $content
* @ return bool
*/
2020-04-24 11:58:51 -07:00
public function isValidAddonMarkup ( $content = '' )
{
2021-01-24 17:00:02 -08:00
if (( strpos ( $content , '<' . '?php' ) !== 0 ))
2020-04-24 11:58:51 -07:00
{
return false ;
}
2017-12-16 11:31:47 -08:00
2020-08-11 08:30:00 -07:00
if (( substr ( $content , - 2 , 2 ) != '?' . '>' ) && ( strrpos ( substr ( $content , - 20 , 20 ), '?' . '>' ) !== false ))
{
return false ;
}
return true ;
2017-12-16 11:31:47 -08:00
2020-04-24 11:58:51 -07:00
}
2017-12-16 11:31:47 -08:00
2017-02-06 08:47:39 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ return array | false
*/
2017-02-06 08:47:39 -08:00
public function getUpgradableList ()
{
$needed = array ();
foreach ( $this -> _installed as $path => $curVal )
{
$version = $this -> load ( $path ) -> getVersion ();
if ( version_compare ( $curVal , $version , " < " )) // check pref version against file version.
{
2020-05-06 13:33:01 -07:00
e107 :: getDebug () -> log ( $curVal . " vs " . $version );
2017-02-06 08:47:39 -08:00
$needed [ $path ] = $version ;
}
}
return ! empty ( $needed ) ? $needed : false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return void | null
*/
2017-02-08 17:37:24 -08:00
private function _initIDs ()
2017-02-03 20:18:45 -08:00
{
$sql = e107 :: getDb ();
2019-01-11 11:39:35 -08:00
$cfg = e107 :: getConfig ();
2017-02-03 20:18:45 -08:00
2019-01-13 13:50:49 -08:00
$pref = $cfg -> get ( 'plug_installed' );
2019-02-20 13:31:42 -08:00
$detected = $this -> getDetected ();
$toRemove = array ();
2019-01-13 13:50:49 -08:00
2019-01-11 11:39:35 -08:00
$save = false ;
2019-02-24 11:35:51 -08:00
if ( $rows = $sql -> retrieve ( " plugin " , " * " , " plugin_id != 0 ORDER by plugin_path " , true ))
2017-02-03 20:18:45 -08:00
{
foreach ( $rows as $row )
{
2019-02-20 13:31:42 -08:00
2017-02-03 20:18:45 -08:00
$path = $row [ 'plugin_path' ];
2019-02-20 13:31:42 -08:00
2019-08-06 11:38:24 -07:00
if ( ! empty ( $detected ) && ! in_array ( $path , $detected ))
2019-02-20 13:31:42 -08:00
{
$toRemove [] = ( int ) $row [ 'plugin_id' ];
continue ;
}
2017-02-03 20:18:45 -08:00
$this -> _ids [ $path ] = ( int ) $row [ 'plugin_id' ];
2019-01-13 14:08:46 -08:00
if ( ! empty ( $row [ 'plugin_installflag' ]) )
2017-02-03 20:18:45 -08:00
{
2017-02-06 08:47:39 -08:00
$this -> _installed [ $path ] = $row [ 'plugin_version' ];
2019-01-13 14:08:46 -08:00
if ( ! isset ( $pref [ $path ]))
{
$cfg -> setPref ( 'plug_installed/' . $path , $row [ 'plugin_version' ]);
2020-12-22 09:36:02 -08:00
e107 :: getLog () -> addDebug ( $path ) -> save ( " plug_installed pref updated " );
2019-01-13 14:08:46 -08:00
$save = true ;
}
2017-02-03 20:18:45 -08:00
}
$this -> _addons [ $path ] = ! empty ( $row [ 'plugin_addons' ]) ? explode ( ',' , $row [ 'plugin_addons' ]) : null ; // $path;
}
2019-01-11 11:39:35 -08:00
if ( $save )
{
$cfg -> save ( false , true , false );
}
2017-02-03 20:18:45 -08:00
}
2017-10-31 14:53:09 -07:00
2017-02-08 17:37:24 -08:00
$runUpdate = false ;
2019-02-20 13:31:42 -08:00
if ( ! empty ( $toRemove ))
{
$runUpdate = true ;
$delList = implode ( " , " , $toRemove );
if ( $sql -> delete ( 'plugin' , " plugin_id IN ( " . $delList . " ) " ))
{
2020-12-22 09:36:02 -08:00
e107 :: getLog () -> addDebug ( " Deleted missing plugins with id(s): " . $delList ) -> save ( " Plugin Table Updated " );
2019-08-06 11:38:24 -07:00
// e107::getDebug()->log("Deleted missing plugins with id(s): ".$delList);
2019-02-20 13:31:42 -08:00
}
}
2020-05-05 15:11:49 -07:00
if ( e_PAGE == 'e107_update.php' )
{
return null ;
}
2017-10-31 14:53:09 -07:00
2017-02-08 17:37:24 -08:00
foreach ( $detected as $path ) // add a missing plugin to the database table.
{
if ( ! isset ( $this -> _ids [ $path ]) && ! empty ( $this -> _data [ $path ][ '@attributes' ]))
{
$this -> load ( $path );
2018-08-03 16:36:21 -07:00
$row = $this -> getFields ();
2017-02-08 17:37:24 -08:00
//var_dump($row);
2018-08-03 16:36:21 -07:00
if ( ! $id = $sql -> insert ( 'plugin' , $row ))
2017-02-08 17:37:24 -08:00
{
e107 :: getDebug () -> log ( " Unable to insert plugin data into table " . print_a ( $row , true ));
2020-12-22 09:36:02 -08:00
e107 :: getLog () -> addDebug ( " Unable to insert plugin data into table " . print_a ( $row , true )) -> save ( " plug_installed pref updated " );
2017-02-08 17:37:24 -08:00
}
else
{
2018-08-03 16:36:21 -07:00
$this -> _ids [ $path ] = ( int ) $id ;
2017-02-08 17:37:24 -08:00
$this -> _addons [ $path ] = ! empty ( $row [ 'plugin_addons' ]) ? explode ( ',' , $row [ 'plugin_addons' ]) : null ;
$runUpdate = true ;
2017-10-31 14:53:09 -07:00
e107 :: getDebug () -> log ( " Inserting plugin data into table " . print_a ( $row , true ));
2020-12-22 09:36:02 -08:00
e107 :: getLog () -> addArray ( $row ) -> save ( " Plugin Table Entry Added " );
2017-10-31 14:53:09 -07:00
2017-02-08 17:37:24 -08:00
if ( $row [ 'plugin_installflag' ] == 1 )
{
e107 :: getConfig () -> setPref ( 'plug_installed/' . $path , $row [ 'plugin_version' ]) -> save ( false , true , false );
}
}
}
}
if ( $runUpdate === true ) // clearCache
{
$this -> _init ( true );
}
2017-02-03 20:18:45 -08:00
2017-02-08 17:37:24 -08:00
}
2017-02-03 20:18:45 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $currentStatus
* @ return array
*/
2018-08-05 15:08:54 -07:00
public function getFields ( $currentStatus = false )
2017-02-08 17:37:24 -08:00
{
2019-01-11 11:39:35 -08:00
/* if ( ! isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'name' ]))
{
return false ;
} */
2017-02-08 17:37:24 -08:00
$ret = array (
'plugin_name' => $this -> getName ( 'db' ),
'plugin_version' => $this -> getVersion (),
'plugin_path' => $this -> _plugdir ,
'plugin_installflag' => ( $this -> getInstallRequired () === true ) ? 0 : 1 ,
'plugin_addons' => $this -> getAddons (),
'plugin_category' => $this -> getCategory ()
);
2018-08-05 15:08:54 -07:00
if ( $currentStatus )
2018-08-03 16:36:21 -07:00
{
2018-08-05 15:08:54 -07:00
$ret [ 'plugin_installflag' ] = ( int ) $this -> isInstalled ();
2018-08-03 16:36:21 -07:00
$ret [ 'plugin_id' ] = $this -> getId ();
}
2017-02-08 17:37:24 -08:00
return $ret ;
2017-02-03 20:18:45 -08:00
}
2017-02-08 17:37:24 -08:00
/**
* Returns a list of addons available for the currently loaded plugin .
* @ return string ( comma separated )
*/
public function getAddons ()
{
2018-11-29 11:35:35 -08:00
$allFiles = isset ( $this -> _data [ $this -> _plugdir ]) ? $this -> _data [ $this -> _plugdir ][ 'files' ] : array ();
2017-02-08 17:37:24 -08:00
$addons = array ();
foreach ( $this -> _addon_types as $ad )
{
$file = $ad . " .php " ;
if ( in_array ( $file , $allFiles ))
{
$addons [] = $ad ;
}
}
foreach ( $allFiles as $file )
{
if ( substr ( $file , - 8 ) === " _sql.php " )
{
$addons [] = str_replace ( " .php " , '' , $file );
}
if ( substr ( $file , - 3 ) === " .bb " )
{
$addons [] = $file ;
}
if ( substr ( $file , - 3 ) === " .sc " )
{
$addons [] = $file ;
}
if ( preg_match ( '/^bb_(.*)\.php$/' , $file ))
{
$addons [] = $file ;
}
}
if ( ! empty ( $this -> _data [ $this -> _plugdir ][ 'shortcodes' ]))
{
foreach ( $this -> _data [ $this -> _plugdir ][ 'shortcodes' ] as $val )
{
$addons [] = 'sc_' . $val ;
}
}
2017-12-16 11:31:47 -08:00
2017-02-08 17:37:24 -08:00
return implode ( ',' , $addons );
}
2022-04-04 10:54:24 -07:00
/**
* @ param $force
* @ return bool | null
*/
2017-02-08 17:37:24 -08:00
private function _init ( $force = false )
2017-02-03 20:18:45 -08:00
{
$cacheTag = self :: CACHETAG ;
if ( $force === false && $tmp = e107 :: getCache () -> retrieve ( $cacheTag , self :: CACHETIME , true , true ))
{
$this -> _data = e107 :: unserialize ( $tmp );
return true ;
}
$dirs = scandir ( e_PLUGIN );
$arr = array ();
2017-04-02 15:17:37 -07:00
2017-02-03 20:18:45 -08:00
foreach ( $dirs as $plugName )
{
2017-02-08 17:37:24 -08:00
$ret = null ;
2017-02-03 20:18:45 -08:00
2017-04-02 14:30:30 -07:00
if (( htmlentities ( $plugName ) != $plugName ) || empty ( $plugName ) || $plugName === '.' || $plugName === '..' || ! is_dir ( e_PLUGIN . $plugName ))
2017-02-03 20:18:45 -08:00
{
continue ;
}
if ( file_exists ( e_PLUGIN . $plugName . '/plugin.xml' ))
{
$ret = $this -> parse_plugin_xml ( $plugName );
}
elseif ( file_exists ( e_PLUGIN . $plugName . '/plugin.php' ))
{
$ret = $this -> parse_plugin_php ( $plugName );
}
2019-01-11 11:39:35 -08:00
if ( ! empty ( $ret [ '@attributes' ][ 'name' ])) // make sure it's a valid plugin.
2017-04-02 12:39:50 -07:00
{
$arr [ $plugName ] = $ret ;
}
2017-02-03 20:18:45 -08:00
}
if ( empty ( $arr ))
{
return false ;
}
$cacheSet = e107 :: serialize ( $arr , 'json' );
2020-03-24 13:57:05 -07:00
if ( empty ( $cacheSet ))
{
$error = json_last_error_msg ();
e107 :: getMessage () -> addDebug ( " Plugin Cache JSON encoding is failing! ( " . __METHOD__ . " ) Line: " . __LINE__ );
e107 :: getMessage () -> addDebug ( " JSON Error: " . $error );
}
2017-02-03 20:18:45 -08:00
e107 :: getCache () -> set ( $cacheTag , $cacheSet , true , true , true );
$this -> _data = $arr ;
2018-08-05 15:08:54 -07:00
return null ;
2017-02-03 20:18:45 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return false | mixed
*/
2017-02-04 12:49:44 -08:00
public function getMeta ()
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
if ( isset ( $this -> _data [ $this -> _plugdir ]))
2017-02-03 20:18:45 -08:00
{
2017-02-04 12:49:44 -08:00
return $this -> _data [ $this -> _plugdir ];
2017-02-03 20:18:45 -08:00
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $mode
* @ return false | mixed | string
*/
2017-02-08 17:37:24 -08:00
public function getName ( $mode = null )
2017-02-03 20:18:45 -08:00
{
2018-08-03 16:36:21 -07:00
if ( ! empty ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'lan' ]))
2017-02-03 20:18:45 -08:00
{
2018-08-03 16:36:21 -07:00
if ( $mode === 'db' )
{
return $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'lan' ];
}
elseif ( defined ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'lan' ]))
{
return constant ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'lan' ]);
}
2017-02-03 20:18:45 -08:00
}
2017-02-04 12:49:44 -08:00
if ( isset ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'name' ]))
2017-02-03 20:18:45 -08:00
{
2017-02-08 17:37:24 -08:00
return ( $mode === 'db' ) ? $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'name' ] : e107 :: getParser () -> toHTML ( $this -> _data [ $this -> _plugdir ][ '@attributes' ][ 'name' ], FALSE , " defs, emotes_off " );
2017-02-03 20:18:45 -08:00
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param string $plugName plugin folder name
* @ return array | false
*/
2017-02-03 20:18:45 -08:00
private function parse_plugin_xml ( $plugName )
{
2018-08-05 15:08:54 -07:00
// $tp = e107::getParser();
2017-02-03 20:18:45 -08:00
// loadLanFiles($plugName, 'admin'); // Look for LAN files on default paths
$xml = e107 :: getXml ();
$mes = e107 :: getMessage ();
2017-02-06 08:47:39 -08:00
2017-02-03 20:18:45 -08:00
// $xml->setOptArrayTags('extendedField,userclass,menuLink,commentID'); // always arrays for these tags.
// $xml->setOptStringTags('install,uninstall,upgrade');
// if(null === $where) $where = 'plugin.xml';
$where = 'plugin.xml' ;
$ret = $xml -> loadXMLfile ( e_PLUGIN . $plugName . '/' . $where , 'advanced' );
if ( $ret === FALSE )
{
$mes -> addError ( " Error reading { $plugName } /plugin.xml " );
return FALSE ;
}
$ret [ 'folder' ] = $plugName ; // remove the need for <folder> tag in plugin.xml.
$ret [ 'category' ] = ( isset ( $ret [ 'category' ])) ? $this -> checkCategory ( $ret [ 'category' ]) : " misc " ;
$ret [ 'files' ] = preg_grep ( '/^([^.])/' , scandir ( e_PLUGIN . $plugName , SCANDIR_SORT_ASCENDING ));
2019-01-13 13:30:58 -08:00
$ret [ 'lan' ] = $this -> _detectLanGlobal ( $plugName );
2017-02-05 15:49:03 -08:00
$ret [ '@attributes' ][ 'version' ] = $this -> _fixVersion ( $ret [ '@attributes' ][ 'version' ]);
$ret [ '@attributes' ][ 'compatibility' ] = $this -> _fixCompat ( $ret [ '@attributes' ][ 'compatibility' ]);
2017-02-03 20:18:45 -08:00
if ( varset ( $ret [ 'description' ]))
{
if ( is_array ( $ret [ 'description' ]))
{
if ( isset ( $ret [ 'description' ][ '@attributes' ][ 'lan' ]) && defined ( $ret [ 'description' ][ '@attributes' ][ 'lan' ]))
{
// Pick up the language-specific description if it exists.
$ret [ 'description' ][ '@value' ] = constant ( $ret [ 'description' ][ '@attributes' ][ 'lan' ]);
}
}
else
{
$diz = $ret [ 'description' ];
unset ( $ret [ 'description' ]);
$ret [ 'description' ][ '@value' ] = $diz ;
}
}
// Very useful debug code.to compare plugin.php vs plugin.xml
/*
$testplug = 'forum' ;
if ( $plugName == $testplug )
{
$plug_vars1 = $ret ;
$this -> parse_plugin_php ( $testplug );
$plug_vars2 = $ret ;
ksort ( $plug_vars2 );
ksort ( $plug_vars1 );
echo " <table>
< tr >< td >< h1 > PHP </ h1 ></ td >< td >< h1 > XML </ h1 ></ td ></ tr >
< tr >< td style = 'border-right:1px solid black' > " ;
print_a ( $plug_vars2 );
echo " </td><td> " ;
print_a ( $plug_vars1 );
echo " </table> " ;
}
*/
// TODO search for $ret['adminLinks']['link'][0]['@attributes']['primary']==true.
$ret [ 'administration' ][ 'icon' ] = varset ( $ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'icon' ]);
$ret [ 'administration' ][ 'caption' ] = varset ( $ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'description' ]);
$ret [ 'administration' ][ 'iconSmall' ] = varset ( $ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'iconSmall' ]);
$ret [ 'administration' ][ 'configFile' ] = varset ( $ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ]);
2017-02-06 08:47:39 -08:00
$ret [ 'legacy' ] = false ;
2017-02-03 20:18:45 -08:00
2017-02-08 17:37:24 -08:00
if ( is_dir ( e_PLUGIN . $plugName . " /shortcodes/single/ " ))
{
$ret [ 'shortcodes' ] = preg_grep ( '/^([^.])/' , scandir ( e_PLUGIN . $plugName , SCANDIR_SORT_ASCENDING ));
}
2017-02-03 20:18:45 -08:00
return $ret ;
}
2018-08-05 15:08:54 -07:00
/**
* @ param $plugName
* @ return array
*/
2017-02-03 20:18:45 -08:00
private function parse_plugin_php ( $plugName )
{
$tp = e107 :: getParser ();
$sql = e107 :: getDb (); // in case it is used inside plugin.php
$PLUGINS_FOLDER = '{e_PLUGIN}' ; // Could be used in plugin.php file.
$eplug_conffile = null ;
$eplug_table_names = null ;
$eplug_prefs = null ;
$eplug_module = null ;
$eplug_userclass = null ;
$eplug_status = null ;
$eplug_latest = null ;
$eplug_icon = null ;
$eplug_icon_small = null ;
2017-02-05 15:49:03 -08:00
$eplug_compatible = null ;
$eplug_version = null ;
2017-02-03 20:18:45 -08:00
ob_start ();
2018-08-05 15:08:54 -07:00
include ( e_PLUGIN . $plugName . '/plugin.php' );
2017-02-03 20:18:45 -08:00
ob_end_clean ();
$ret = array ();
2018-08-05 15:08:54 -07:00
unset ( $sql );
unset ( $PLUGINS_FOLDER );
2017-02-03 20:18:45 -08:00
$ret [ '@attributes' ][ 'name' ] = varset ( $eplug_name );
$ret [ '@attributes' ][ 'lan' ] = varset ( $eplug_name );
2020-05-06 13:33:01 -07:00
$ret [ '@attributes' ][ 'version' ] = $this -> _fixVersion ( $eplug_version , true );
2017-02-03 20:18:45 -08:00
$ret [ '@attributes' ][ 'date' ] = varset ( $eplug_date );
2017-02-05 15:49:03 -08:00
$ret [ '@attributes' ][ 'compatibility' ] = $this -> _fixCompat ( $eplug_compatible );
2017-02-03 20:18:45 -08:00
$ret [ '@attributes' ][ 'installRequired' ] = ( $eplug_conffile || is_array ( $eplug_table_names ) || is_array ( $eplug_prefs ) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest ) ? 'true' : '' ;
$ret [ '@attributes' ][ 'xhtmlcompliant' ] = vartrue ( $eplug_compliant ) ? 'true' : '' ;
$ret [ 'folder' ] = $plugName ; // (varset($eplug_folder)) ? $eplug_folder : $plugName;
$ret [ 'author' ][ '@attributes' ][ 'name' ] = varset ( $eplug_author );
$ret [ 'author' ][ '@attributes' ][ 'url' ] = varset ( $eplug_url );
$ret [ 'author' ][ '@attributes' ][ 'email' ] = varset ( $eplug_email );
$ret [ 'description' ][ '@value' ] = varset ( $eplug_description );
$ret [ 'description' ][ '@attributes' ][ 'lan' ] = varset ( $eplug_description );
$ret [ 'category' ] = ! empty ( $eplug_category ) ? $this -> checkCategory ( $eplug_category ) : " misc " ;
$ret [ 'readme' ] = ! empty ( $eplug_readme );
$ret [ 'menuName' ] = varset ( $eplug_menu_name );
if ( ! empty ( $eplug_prefs ) && is_array ( $eplug_prefs ))
{
$c = 0 ;
foreach ( $eplug_prefs as $name => $value )
{
$ret [ 'mainPrefs' ][ 'pref' ][ $c ][ '@attributes' ][ 'name' ] = $name ;
$ret [ 'mainPrefs' ][ 'pref' ][ $c ][ '@value' ] = $value ;
$c ++ ;
}
}
2017-02-05 15:49:03 -08:00
2017-02-03 20:18:45 -08:00
// For BC.
2017-02-05 15:49:03 -08:00
$ret [ 'administration' ][ 'icon' ] = $this -> _fixPath ( $eplug_icon , $plugName );
2017-02-03 20:18:45 -08:00
$ret [ 'administration' ][ 'caption' ] = varset ( $eplug_caption );
2017-02-05 15:49:03 -08:00
$ret [ 'administration' ][ 'iconSmall' ] = $this -> _fixPath ( $eplug_icon_small , $plugName );
2017-02-03 20:18:45 -08:00
$ret [ 'administration' ][ 'configFile' ] = varset ( $eplug_conffile );
2017-02-05 15:49:03 -08:00
2017-02-03 20:18:45 -08:00
if ( isset ( $eplug_conffile ))
{
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ] = varset ( $eplug_conffile );
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'description' ] = LAN_CONFIGURE ;
2017-02-05 15:49:03 -08:00
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'icon' ] = $this -> _fixPath ( $eplug_icon , $plugName ); // str_replace($plugName."/","",$eplug_icon);
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'iconSmall' ] = $this -> _fixPath ( $eplug_icon_small , $plugName );
2017-02-03 20:18:45 -08:00
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'primary' ] = 'true' ;
}
if ( ! empty ( $eplug_link ) && isset ( $eplug_link_name ) && isset ( $eplug_link_url ))
{
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ] = $tp -> createConstants ( $eplug_link_url , 1 );
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'perm' ] = varset ( $eplug_link_perms );
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@value' ] = varset ( $eplug_link_name );
}
if ( ! empty ( $eplug_userclass ) && ! empty ( $eplug_userclass_description ))
{
$ret [ 'userClasses' ][ 'class' ][ 0 ][ '@attributes' ][ 'name' ] = $eplug_userclass ;
$ret [ 'userClasses' ][ 'class' ][ 0 ][ '@attributes' ][ 'description' ] = $eplug_userclass_description ;
}
$ret [ 'files' ] = preg_grep ( '/^([^.])/' , scandir ( e_PLUGIN . $plugName , SCANDIR_SORT_ASCENDING ));
2019-01-13 13:30:58 -08:00
$ret [ 'lan' ] = $this -> _detectLanGlobal ( $plugName );
2017-02-06 08:47:39 -08:00
$ret [ 'legacy' ] = true ;
2017-02-03 20:18:45 -08:00
return $ret ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $pluginDir
* @ return false | mixed
*/
2019-01-13 13:30:58 -08:00
private function _detectLanGlobal ( $pluginDir )
{
$path_a = e_PLUGIN . $pluginDir . " /languages/English_global.php " ; // always check for English so we have a fall-back
$path_b = e_PLUGIN . $pluginDir . " /languages/English/English_global.php " ;
if ( file_exists ( $path_a ) || file_exists ( $path_b ))
{
return $pluginDir ;
}
return false ;
}
2017-02-03 20:18:45 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $ver
* @ param $legacy
* @ return array | string | string [] | null
*/
2020-05-06 13:33:01 -07:00
private function _fixVersion ( $ver , $legacy = false )
2017-02-05 15:49:03 -08:00
{
if ( empty ( $ver ))
{
2021-09-04 15:06:19 +02:00
return '' ;
2017-02-05 15:49:03 -08:00
}
$ver = str_replace ( 'e107' , '' , $ver );
2020-05-06 13:33:01 -07:00
$regex = ( $legacy === true ) ? '/([^\d\.ab])/' : '/([^\d\.])/' ;
2017-02-05 15:49:03 -08:00
2020-05-06 13:33:01 -07:00
return preg_replace ( $regex , '' , $ver ); // eg. 2.0.1b okay for BC plugin.
2017-02-05 15:49:03 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $ver
* @ return array | string | string []
*/
2017-02-05 15:49:03 -08:00
private function _fixCompat ( $ver )
{
$ver = $this -> _fixVersion ( $ver );
$ver = str_replace ( '0.8' , '2.0' , $ver );
if ( $ver == 7 || intval ( $ver ) < 1 )
{
$ver = " 1.0 " ;
}
return $ver ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $path
* @ param $plugName
* @ return array | string | string []
*/
2017-02-05 15:49:03 -08:00
private function _fixPath ( $path , $plugName )
{
$pathFilter = array (
e_PLUGIN . $plugName . '/' ,
$plugName . " / "
);
2021-09-04 15:06:19 +02:00
return str_replace ( $pathFilter , '' , ( string ) $path );
2017-02-05 15:49:03 -08:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $cat
* @ return mixed | string
*/
2017-02-03 20:18:45 -08:00
private function checkCategory ( $cat )
{
2017-02-06 11:18:36 -08:00
$okayCats = array_keys ( $this -> _accepted_categories );
if ( ! empty ( $cat ) && in_array ( $cat , $okayCats ))
2017-02-03 20:18:45 -08:00
{
return $cat ;
}
else
{
return 'misc' ;
}
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2017-12-16 11:31:47 -08:00
public function buildAddonPrefLists ()
{
$core = e107 :: getConfig ( 'core' );
2018-12-17 10:40:33 -08:00
$urlsBefore = $core -> get ( 'e_url_list' , array ()); // get URL settings to be restored after.
2017-12-16 11:31:47 -08:00
foreach ( $this -> _addon_types as $var ) // clear all existing prefs.
{
$core -> update ( $var . '_list' , " " );
}
// reset
$core -> set ( 'bbcode_list' , array ())
-> set ( 'shortcode_legacy_list' , array ())
2019-01-13 13:30:58 -08:00
-> set ( 'shortcode_list' , array ())
2020-12-12 12:40:26 -08:00
-> set ( 'lan_global_list' , array ())
-> set ( 'wysiwyg_list' , array ());
2017-12-16 11:31:47 -08:00
2018-11-01 09:59:17 -05:00
$paths = $this -> getDetected ();
2017-12-16 11:31:47 -08:00
2018-11-01 09:59:17 -05:00
/**
* Prevent this method from wiping out the variable that is tracking
* the currently loaded plugin by moving the currently loaded plugin to
* the end of the iterated array .
* @ see https :// github . com / e107inc / e107 / issues / 3531
* @ see https :// github . com / e107inc / e107 - test / issues / 9
*/
$paths = array_diff ( $paths , [ $this -> _plugdir ]);
$paths [] = $this -> _plugdir ;
foreach ( $paths as $path )
2017-12-16 11:31:47 -08:00
{
$this -> load ( $path );
$is_installed = $this -> isInstalled ();
$tmp = explode ( " , " , $this -> getAddons ());
if ( $is_installed )
{
2019-01-13 13:30:58 -08:00
if ( $hasLAN = $this -> hasLanGlobal ())
{
$core -> setPref ( 'lan_global_list/' . $hasLAN , $hasLAN );
}
2017-12-16 11:31:47 -08:00
foreach ( $tmp as $val )
{
if ( strpos ( $val , 'e_' ) === 0 )
{
$core -> setPref ( $val . '_list/' . $path , $path );
}
}
}
// search for .bb and .sc files.
$scl_array = array ();
$sc_array = array ();
$bb_array = array ();
// $sql_array = array();
foreach ( $tmp as $adds )
{
// legacy shortcodes - plugin root *.sc files
if ( substr ( $adds , - 3 ) === " .sc " )
{
$sc_name = substr ( $adds , 0 , - 3 ); // remove the .sc
if ( $is_installed )
{
$scl_array [ $sc_name ] = " 0 " ; // default userclass = e_UC_PUBLIC
}
else
{
$scl_array [ $sc_name ] = e_UC_NOBODY ; // register shortcode, but disable it
}
}
// new shortcodes location - shortcodes/single/*.php
2021-01-24 17:00:02 -08:00
elseif ( strpos ( $adds , " sc_ " ) === 0 )
2017-12-16 11:31:47 -08:00
{
$sc_name = substr ( substr ( $adds , 3 ), 0 , - 4 ); // remove the sc_ and .php
if ( $is_installed )
{
$sc_array [ $sc_name ] = " 0 " ; // default userclass = e_UC_PUBLIC
}
else
{
$sc_array [ $sc_name ] = e_UC_NOBODY ; // register shortcode, but disable it
}
}
if ( $is_installed )
{
// simple bbcode
if ( substr ( $adds , - 3 ) == " .bb " )
{
$bb_name = substr ( $adds , 0 , - 3 ); // remove the .bb
$bb_array [ $bb_name ] = " 0 " ; // default userclass.
}
// bbcode class
2021-01-24 17:00:02 -08:00
elseif ( strpos ( $adds , " bb_ " ) === 0 && substr ( $adds , - 4 ) == " .php " )
2017-12-16 11:31:47 -08:00
{
$bb_name = substr ( $adds , 0 , - 4 ); // remove the .php
$bb_name = substr ( $bb_name , 3 );
$bb_array [ $bb_name ] = " 0 " ; // TODO - instance and getPermissions() method
}
}
if ( $is_installed && ( substr ( $adds , - 4 ) == " _sql " ))
{
$core -> setPref ( 'e_sql_list/' . $path , $adds );
}
}
// Build Bbcode list (will be empty if plugin not installed)
if ( count ( $bb_array ) > 0 )
{
ksort ( $bb_array );
$core -> setPref ( 'bbcode_list/' . $path , $bb_array );
}
// Build shortcode list - do if uninstalled as well
if ( count ( $scl_array ) > 0 )
{
ksort ( $scl_array );
$core -> setPref ( 'shortcode_legacy_list/' . $path , $scl_array );
}
if ( count ( $sc_array ) > 0 )
{
ksort ( $sc_array );
$core -> setPref ( 'shortcode_list/' . $path , $sc_array );
}
}
2018-12-17 10:40:33 -08:00
// Restore e_url settings
$urlsAfter = $core -> get ( 'e_url_list' , array ());
foreach ( $urlsAfter as $k => $v )
{
if ( isset ( $urlsBefore [ $k ]))
{
$core -> setPref ( 'e_url_list/' . $k , $urlsBefore [ $k ]);
}
}
2017-12-16 11:31:47 -08:00
2020-12-12 12:40:26 -08:00
$editors = $this -> getInstalledWysiwygEditors ();
$core -> setPref ( 'wysiwyg_list' , $editors );
2017-12-16 11:31:47 -08:00
2018-12-17 10:40:33 -08:00
$core -> save ( false , true , false );
2017-12-16 11:31:47 -08:00
}
2017-02-03 20:18:45 -08:00
}
2018-08-03 16:36:21 -07:00
/**
2020-12-18 09:39:02 -08:00
* @ outdated in part . To eventually be replaced with e_plugin above .
2018-08-03 16:36:21 -07:00
*/
2006-12-02 04:36:16 +00:00
class e107plugin
{
2009-12-09 22:38:18 +00:00
// Reserved Addon names.
2010-06-23 10:21:21 +00:00
var $plugin_addons = array (
2015-04-07 19:49:11 -07:00
'e_admin' ,
2014-01-22 06:10:44 -08:00
'e_bb' ,
'e_cron' ,
2009-09-25 20:14:29 +00:00
'e_notify' ,
'e_linkgen' ,
'e_list' ,
2014-01-22 06:10:44 -08:00
2015-01-29 13:09:22 -08:00
'e_meta' , // @Deprecated
2009-09-25 20:14:29 +00:00
'e_emailprint' ,
2019-03-11 16:30:01 -07:00
'e_print' , // new v2.2
2009-09-25 20:14:29 +00:00
'e_frontpage' ,
2016-08-01 12:58:03 -07:00
'e_latest' , /* @deprecated - see e_dashboard */
'e_status' , /* @deprecated - see e_dashboard */
2016-04-10 18:47:40 -07:00
'e_menu' ,
2009-09-25 20:14:29 +00:00
'e_search' ,
'e_shortcode' ,
'e_module' ,
'e_event' ,
'e_comment' ,
'e_sql' ,
2015-01-09 21:43:16 -08:00
'e_dashboard' , // Admin Front-Page addon.
2014-10-14 02:09:53 -07:00
// 'e_userprofile', @deprecated @see e_user
2015-01-29 11:26:56 -08:00
'e_header' , // loaded in header prior to javascript manager.
'e_footer' , // Loaded in footer prior to javascript manager.
2014-10-14 02:09:53 -07:00
// 'e_userinfo', @deprecated @see e_user
2009-10-09 18:58:12 +00:00
'e_tagwords' ,
2015-01-09 21:43:16 -08:00
'e_url' , // simple mod-rewrite.
2009-11-20 05:01:51 +00:00
'e_mailout' ,
2015-01-29 11:26:56 -08:00
'e_sitelink' , // sitelinks generator.
2016-08-01 12:58:03 -07:00
'e_tohtml' , /* @deprecated - use e_parse */
2014-01-22 06:10:44 -08:00
'e_featurebox' ,
2016-08-01 12:58:03 -07:00
'e_parse' ,
2014-01-22 06:10:44 -08:00
'e_related' ,
'e_rss' ,
2015-02-07 01:42:44 -08:00
'e_upload' ,
2016-02-12 10:18:13 +01:00
'e_user' ,
'e_library' , // For third-party libraries are defined by plugins/themes.
2018-01-29 12:03:15 -08:00
'e_gsitemap' ,
2018-06-12 18:09:00 +02:00
'e_output' , //hook into all pages at the end (after closing </html>)
2010-06-23 10:21:21 +00:00
);
2006-12-02 04:36:16 +00:00
2012-11-27 23:03:17 -08:00
2016-04-10 18:47:40 -07:00
/** Deprecated or non-v2.x standards */
private $plugin_addons_deprecated = array (
'e_bb' , // @deprecated
'e_list' ,
'e_meta' , // @deprecated
'e_latest' , // @deprecated
'e_status' , // @deprecated
'e_tagwords' ,
'e_sql.php' ,
'e_linkgen' ,
'e_frontpage' ,
'e_tohtml' , // @deprecated rename to e_parser ?
'e_sql' ,
'e_emailprint' ,
);
private $plugin_addons_diz = array (
'e_admin' => " Add form elements to existing core admin areas. " ,
'e_cron' => " Include your plugin's cron in the 'Scheduled Tasks' admin area. " ,
'e_notify' => " Include your plugin's notification to the Notify admin area. " ,
'e_linkgen' => " Add link generation into the sitelinks area. " ,
'e_frontpage' => " Add your plugin as a frontpage option. " ,
'e_menu' => " Gives your plugin's menu(s) configuration options in the Menu Manager. " ,
'e_featurebox' => " Allow your plugin to generate content for the featurebox plugin. " ,
'e_search' => " Add your plugin to the search page. " ,
'e_shortcode' => " Add a global shortcode which can be used site-wide. (use sparingly) " ,
'e_module' => " Include a file within class2.php (every page of the site). " ,
'e_event' => " Hook into core events and process them with custom functions. " ,
'e_comment' => " Override the core commenting system. " ,
'e_dashboard' => " Add something to the default admin dashboard panel. " , // Admin Front-Page addon.
'e_header' => " Have your plugin include code in the head of every page of the site. eg. css " , // loaded in header prior to javascript manager.
'e_footer' => " Have your plugin include code in the foot of every page of the site. eg. javascript " , // Loaded in footer prior to javascript manager.
'e_url' => " Give your plugin search-engine-friendly URLs " , // simple mod-rewrite.
'e_mailout' => " Allow the mailing engine to use data from your plugin's database tables. " ,
'e_sitelink' => " Create dynamic navigation links for your plugin. " , // sitelinks generator.
'e_related' => " Allow your plugin to be included in the 'related' links. " ,
'e_rss' => " Give your plugin an rss feed. " ,
'e_upload' => " Use data from your plugin in the user upload form. " ,
'e_user' => " Have your plugin include data on the user-profile page. " ,
2017-09-20 16:23:17 -07:00
'e_library' => " Include a third-party library " ,
2018-06-12 11:07:21 +02:00
'e_parse' => " Hook into e107's text/html parser " ,
2018-06-12 18:09:00 +02:00
'e_output' => " Hook into all pages at the end (after closing </html>) "
2016-04-10 18:47:40 -07:00
);
2012-11-27 23:03:17 -08:00
var $disAllowed = array (
2012-12-02 22:31:46 -08:00
'theme' ,
'core'
2012-11-27 23:03:17 -08:00
);
2014-01-25 15:56:20 -08:00
protected $core_plugins = array (
2017-04-23 12:38:05 -07:00
" _blank " , " admin_menu " , " banner " , " blogcalendar_menu " ,
2021-01-24 07:38:19 -08:00
" chatbox_menu " , " comment_menu " ,
2017-04-23 12:38:05 -07:00
" contact " , " download " , " featurebox " , " forum " , " gallery " ,
2020-12-16 15:46:11 -08:00
" gsitemap " , " hero " , " import " , " linkwords " , " list_new " , " log " , " login_menu " ,
2014-01-25 15:56:20 -08:00
" metaweblog " , " newforumposts_main " , " news " , " newsfeed " ,
2015-02-01 02:07:56 -08:00
" newsletter " , " online " , " page " , " pm " , " poll " ,
2017-04-23 12:38:05 -07:00
" rss_menu " , " search_menu " , " siteinfo " , " social " , " tagcloud " , " tinymce4 " ,
2020-12-29 10:30:05 -08:00
" user "
2014-01-25 15:56:20 -08:00
);
2007-02-01 22:00:41 +00:00
// List of all plugin variables which need to be checked - install required if one or more set and non-empty
2008-08-09 16:49:58 +00:00
// Deprecated in 0.8 (used in plugin.php only). Probably delete in 0.9
2007-02-01 22:00:41 +00:00
var $all_eplug_install_variables = array (
2009-09-21 21:53:38 +00:00
'eplug_link_url' ,
'eplug_link' ,
'eplug_prefs' ,
'eplug_array_pref' ,
'eplug_table_names' ,
2010-06-23 10:21:21 +00:00
// 'eplug_sc', // Not used in 0.8 (or later 0.7)
2009-09-21 21:53:38 +00:00
'eplug_userclass' ,
'eplug_module' ,
2010-06-23 10:21:21 +00:00
// 'eplug_bb', // Not used in 0.8 (or later 0.7)
2009-09-21 21:53:38 +00:00
'eplug_latest' ,
'eplug_status' ,
'eplug_comment_ids' ,
'eplug_conffile' ,
'eplug_menu_name'
2007-02-01 22:00:41 +00:00
);
// List of all plugin variables involved in an update (not used ATM, but worth 'documenting')
2008-08-09 16:49:58 +00:00
// Deprecated in 0.8 (used in plugin.php only). Probably delete in 0.9
2010-06-23 10:21:21 +00:00
var $all_eplug_update_variables = array (
2009-09-21 21:53:38 +00:00
'upgrade_alter_tables' ,
2010-06-23 10:21:21 +00:00
// 'upgrade_add_eplug_sc', // Not used in 0.8 (or later 0.7)
// 'upgrade_remove_eplug_sc', // Not used in 0.8 (or later 0.7)
// 'upgrade_add_eplug_bb', // Not used in 0.8 (or later 0.7)
// 'upgrade_remove_eplug_bb', // Not used in 0.8 (or later 0.7)
2009-09-21 21:53:38 +00:00
'upgrade_add_prefs' ,
'upgrade_remove_prefs' ,
'upgrade_add_array_pref' ,
'upgrade_remove_array_pref'
2007-02-01 22:00:41 +00:00
);
2008-01-20 15:01:19 +00:00
2007-06-05 19:51:36 +00:00
// List of all 'editable' DB fields ('plugin_id' is an arbitrary reference which is never edited)
2010-06-23 10:21:21 +00:00
var $all_editable_db_fields = array (
'plugin_name' , // Name of the plugin - language dependent
'plugin_version' , // Version - arbitrary text field
'plugin_path' , // Name of the directory off e_PLUGIN - unique
'plugin_installflag' , // '0' = not installed, '1' = installed
'plugin_addons' , // List of any extras associated with plugin - bbcodes, e_XXX files...
'plugin_category' // Plugin Category: settings, users, content, management, tools, misc, about
);
2008-01-20 15:01:19 +00:00
2009-09-19 17:43:19 +00:00
var $accepted_categories = array ( 'settings' , 'users' , 'content' , 'tools' , 'manage' , 'misc' , 'menu' , 'about' );
2009-09-14 11:27:45 +00:00
2008-01-27 01:34:59 +00:00
var $plug_vars ;
2008-02-02 03:23:47 +00:00
var $current_plug ;
2014-01-20 06:20:58 -08:00
var $parsed_plugin = array ();
2009-09-23 23:18:18 +00:00
var $plugFolder ;
2009-10-20 03:49:28 +00:00
var $plugConfigFile ;
2009-09-23 23:18:18 +00:00
var $unInstallOpts ;
2008-11-24 00:36:50 +00:00
var $module = array ();
2014-01-20 06:20:58 -08:00
private $options = array ();
2017-01-26 15:37:42 -08:00
private $log = array ();
2009-12-09 22:38:18 +00:00
2017-02-03 20:18:45 -08:00
2014-01-20 06:20:58 -08:00
function __construct ()
2008-01-28 02:49:50 +00:00
{
2014-01-20 06:20:58 -08:00
//$parsed_plugin = array();
2008-01-28 02:49:50 +00:00
}
2008-02-01 14:11:27 +00:00
2009-12-09 22:38:18 +00:00
2014-01-25 15:56:20 -08:00
/**
* Return a list of core plugins .
*/
public function getCorePlugins ()
{
return $this -> core_plugins ;
}
/**
* Return a list of non - core plugins
*/
public function getOtherPlugins ()
{
$allplugs = e107 :: getFile () -> get_dirs ( e_PLUGIN );
return array_diff ( $allplugs , $this -> core_plugins );
}
2012-12-08 00:36:34 -08:00
2014-01-25 15:56:20 -08:00
/**
2012-12-08 00:36:34 -08:00
* Returns an array containing details of all plugins in the plugin table - should normally use e107plugin :: update_plugins_table () first to
* make sure the table is up to date . ( Primarily called from plugin manager to get lists of installed and uninstalled plugins .
2015-10-02 13:40:44 +03:00
* @ param string $path
* @ return int
2012-12-08 00:36:34 -08:00
*/
2018-08-06 13:07:13 -07:00
private function getId ( $path )
2012-12-08 00:36:34 -08:00
{
$sql = e107 :: getDb ();
2013-02-22 15:43:58 -08:00
if ( $sql -> select ( " plugin " , " plugin_id " , " plugin_path = ' " . ( string ) $path . " ' LIMIT 1 " ))
2012-12-08 00:36:34 -08:00
{
2016-02-14 12:15:55 -08:00
$row = $sql -> fetch ();
2012-12-08 00:36:34 -08:00
return intval ( $row [ 'plugin_id' ]);
}
return false ;
}
/**
* Checks all installed plugins and returns an array of those needing an update .
* @ param string $mode 'boolean' for a quick true / false or null for full array returned .
2022-04-04 10:54:24 -07:00
* @ return array | bool
2012-12-08 00:36:34 -08:00
*/
2018-08-06 13:07:13 -07:00
public function updateRequired ( $mode = null )
2012-12-08 00:36:34 -08:00
{
2018-08-06 13:07:13 -07:00
// $xml = e107::getXml();
2012-12-08 00:36:34 -08:00
$mes = e107 :: getMessage ();
$needed = array ();
2020-12-22 09:36:02 -08:00
$log = e107 :: getLog ();
2017-11-07 17:52:15 -08:00
2012-12-16 14:28:30 -08:00
if ( ! $plugVersions = e107 :: getConfig ( 'core' ) -> get ( 'plug_installed' ))
{
return FALSE ;
}
2017-04-21 14:21:29 -07:00
2017-04-27 15:31:01 -07:00
$dbv = e107 :: getObject ( 'db_verify' , null , e_HANDLER . " db_verify_class.php " );
2017-02-06 08:47:39 -08:00
$plg = e107 :: getPlug ();
2012-12-08 00:36:34 -08:00
foreach ( $plugVersions as $path => $version )
{
2017-11-07 17:52:15 -08:00
$data = $plg -> load ( $path ) -> getMeta ();
2017-02-06 08:47:39 -08:00
if ( $plg -> isLegacy () === true )
{
continue ;
}
2018-07-24 12:03:26 -07:00
if ( ! in_array ( $path , $this -> core_plugins )) // check non-core plugins for sql file changes.
2017-02-06 08:47:39 -08:00
{
$dbv -> errors = array ();
$dbv -> compare ( $path );
2015-01-27 13:00:33 -08:00
2017-02-06 08:47:39 -08:00
if ( $dbv -> errors ())
{
2017-04-21 14:21:29 -07:00
$mes -> addDebug ( " Plugin Update(s) Required - db structure change [ " . $path . " ] " );
2017-02-06 08:47:39 -08:00
$needed [ $path ] = $data ;
2015-01-27 13:00:33 -08:00
}
2017-02-06 08:47:39 -08:00
}
2017-02-07 14:51:33 -08:00
2018-07-20 21:25:40 +02:00
$curVal = $version ;
$fileVal = $plg -> getVersion ();
2017-02-06 12:23:42 -08:00
2018-07-20 21:25:40 +02:00
if ( $ret = $this -> execute_function ( $path , 'upgrade' , 'required' , array ( $this , $curVal , $fileVal ))) // Check {plugin}_setup.php and run a 'required' method, if true, then update is required.
{
$mes -> addDebug ( " Plugin Update(s) Required in " . $path . " _setup.php [ " . $path . " ] " );
if ( $mode === 'boolean' )
2012-12-08 00:36:34 -08:00
{
2018-07-20 21:25:40 +02:00
return TRUE ;
}
2017-11-07 17:52:15 -08:00
2018-07-20 21:25:40 +02:00
$needed [ $path ] = $data ;
}
2017-11-07 17:52:15 -08:00
2018-07-20 21:25:40 +02:00
if ( version_compare ( $curVal , $fileVal , " < " )) // check pref version against file version.
{
$mes -> addDebug ( " Plugin Update(s) Required - different version [ " . $path . " ] " );
2017-11-07 17:52:15 -08:00
2018-07-20 21:25:40 +02:00
if ( $mode === 'boolean' )
2012-12-08 00:36:34 -08:00
{
2018-07-20 21:25:40 +02:00
return TRUE ;
}
2017-11-07 17:52:15 -08:00
2018-07-20 21:25:40 +02:00
// $mes->addDebug("Plugin: <strong>{$path}</strong> requires an update.");
2017-02-06 08:47:39 -08:00
2018-07-20 21:25:40 +02:00
// $log->flushMessages();
$needed [ $path ] = $data ;
}
2012-12-08 00:36:34 -08:00
2013-05-15 16:07:10 -07:00
}
// Display debug and log to file.
foreach ( $needed as $path => $tmp )
{
2017-11-07 17:52:15 -08:00
$log -> addDebug ( " Plugin: <strong> { $path } </strong> requires an update. " );
2012-12-08 00:36:34 -08:00
}
2017-04-21 14:21:29 -07:00
2017-11-07 17:52:15 -08:00
if ( $mode === 'boolean' )
{
return count ( $needed ) ? true : FALSE ;
}
2012-12-08 00:36:34 -08:00
return count ( $needed ) ? $needed : FALSE ;
}
2006-12-02 04:36:16 +00:00
2012-12-23 15:00:15 +00:00
2006-12-02 04:36:16 +00:00
/**
2010-06-23 10:21:21 +00:00
* Check for new plugins , create entry in plugin table and remove deleted plugins
2018-08-06 13:07:13 -07:00
* @ deprecated by e_plugin :: init () some parts might still need to be integrated into the new method .
2012-12-23 15:00:15 +00:00
* @ param string $mode = install | upgrade | refresh | uninstall - defines the intent of the call
*
* 'upgrade' and 'refresh' are very similar in intent , and often take the same actions :
* 'upgrade' signals a possible change to the installed list of plugins
* 'refresh' validates the stored data for existing plugins , recreating any that has gone missing
2010-06-23 10:21:21 +00:00
*/
2012-12-23 15:00:15 +00:00
function update_plugins_table ( $mode = 'upgrade' )
2007-02-01 22:00:41 +00:00
{
2012-12-08 00:36:34 -08:00
2013-05-12 20:56:35 -07:00
$sql = e107 :: getDb ();
$sql2 = e107 :: getDb ( 'sql2' );
$tp = e107 :: getParser ();
$fl = e107 :: getFile ();
$mes = e107 :: getMessage ();
2012-12-08 00:36:34 -08:00
$mes -> addDebug ( " Updating plugins Table " );
2013-05-12 20:56:35 -07:00
2020-12-22 09:36:02 -08:00
$log = e107 :: getLog ();
2009-12-09 22:38:18 +00:00
2012-12-08 00:36:34 -08:00
global $mySQLprefix , $menu_pref ;
$pref = e107 :: getPref ();
2006-12-02 04:36:16 +00:00
2007-05-07 13:38:34 +00:00
$sp = FALSE ;
2009-12-09 22:38:18 +00:00
2007-06-05 19:51:36 +00:00
$pluginDBList = array ();
2013-02-25 01:05:35 -08:00
if ( $sql -> select ( 'plugin' , " * " )) // Read all the plugin DB info into an array to save lots of accesses
2010-06-23 10:21:21 +00:00
2007-06-05 19:51:36 +00:00
{
2016-02-14 12:15:55 -08:00
while ( $row = $sql -> fetch ())
2009-12-09 22:38:18 +00:00
{
2008-01-20 15:01:19 +00:00
$pluginDBList [ $row [ 'plugin_path' ]] = $row ;
$pluginDBList [ $row [ 'plugin_path' ]][ 'status' ] = 'read' ;
2009-08-31 02:00:51 +00:00
// echo "Found plugin: ".$row['plugin_path']." in DB<br />";
2010-06-23 10:21:21 +00:00
}
2007-06-05 19:51:36 +00:00
}
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'Start Scanning Plugin Files' );
2009-09-21 21:53:38 +00:00
$plugList = $fl -> get_files ( e_PLUGIN , " ^plugin \ .(php|xml) $ " , " standard " , 1 );
2020-05-02 15:35:30 -07:00
2010-06-23 10:21:21 +00:00
foreach ( $plugList as $num => $val ) // Remove Duplicates caused by having both plugin.php AND plugin.xml.
2008-12-02 21:51:22 +00:00
{
2009-09-21 21:53:38 +00:00
$key = basename ( $val [ 'path' ]);
2010-06-23 10:21:21 +00:00
$pluginList [ $key ] = $val ;
2008-12-02 21:51:22 +00:00
}
2020-05-02 15:35:30 -07:00
e107 :: getDebug () -> logTime ( 'After Scanning Plugin Files' );
2010-06-23 10:21:21 +00:00
$p_installed = e107 :: getPref ( 'plug_installed' , array ()); // load preference;
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2009-08-31 02:00:51 +00:00
2010-06-23 10:21:21 +00:00
foreach ( $pluginList as $p )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
$p [ 'path' ] = substr ( str_replace ( e_PLUGIN , " " , $p [ 'path' ]), 0 , - 1 );
2009-12-09 22:38:18 +00:00
$plugin_path = $p [ 'path' ];
2009-09-10 15:24:57 +00:00
2010-06-23 10:21:21 +00:00
if ( strpos ( $plugin_path , 'e107_' ) !== FALSE )
2009-09-10 15:24:57 +00:00
{
2013-02-27 15:18:48 +01:00
$mes -> addWarning ( " Folder error: <i> { $p [ 'path' ] } </i>. 'e107_' is not permitted within plugin folder names. " );
2009-09-10 15:24:57 +00:00
continue ;
}
2012-11-27 23:03:17 -08:00
2012-11-29 23:12:20 -08:00
if ( in_array ( $plugin_path , $this -> disAllowed ))
2012-11-27 23:03:17 -08:00
{
$mes -> addWarning ( " Folder error: <i> { $p [ 'path' ] } </i> is not permitted as an acceptable folder name. " );
continue ;
}
2010-06-23 10:21:21 +00:00
$plug [ 'plug_action' ] = 'scan' ; // Make sure plugin.php knows what we're up to
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( ! $this -> parse_plugin ( $p [ 'path' ]))
2008-01-20 15:01:19 +00:00
{
2009-12-09 22:38:18 +00:00
//parsing of plugin.php/plugin.xml failed.
2013-02-27 15:18:48 +01:00
$mes -> addError ( " Parsing failed - file format error: { $p [ 'path' ] } " );
2010-06-23 10:21:21 +00:00
continue ; // Carry on and do any others that are OK
2012-08-22 02:45:32 +00:00
}
2009-12-09 22:38:18 +00:00
2008-02-13 00:46:05 +00:00
$plug_info = $this -> plug_vars ;
2009-12-09 22:38:18 +00:00
$eplug_addons = $this -> getAddons ( $plugin_path );
2013-02-11 14:25:59 +02:00
2012-12-12 18:46:34 -08:00
//Ensure the plugin path lives in the same folder as is configured in the plugin.php/plugin.xml - no longer relevant.
2008-03-11 01:47:05 +00:00
if ( $plugin_path == $plug_info [ 'folder' ])
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
if ( array_key_exists ( $plugin_path , $pluginDBList ))
{ // Update the addons needed by the plugin
2008-01-20 15:01:19 +00:00
$pluginDBList [ $plugin_path ][ 'status' ] = 'exists' ;
2012-12-12 18:46:34 -08:00
// Check for name (lan) changes
if ( vartrue ( $plug_info [ '@attributes' ][ 'lan' ]) && $pluginDBList [ $plugin_path ][ 'plugin_name' ] != $plug_info [ '@attributes' ][ 'lan' ])
{
// print_a($plug_info);
$pluginDBList [ $plugin_path ][ 'status' ] = 'update' ;
$pluginDBList [ $plugin_path ][ 'plugin_name' ] = $plug_info [ '@attributes' ][ 'lan' ];
$this -> plugFolder = $plugin_path ;
$this -> XmlLanguageFiles ( 'upgrade' );
}
2012-12-23 15:00:15 +00:00
if ( $mode == 'refresh' )
{
2012-12-28 21:19:22 +00:00
if ( $this -> XmlLanguageFileCheck ( '_log' , 'lan_log_list' , 'refresh' , $pluginDBList [ $plugin_path ][ 'plugin_installflag' ], FALSE , $plugin_path )) $sp = TRUE ;
if ( $this -> XmlLanguageFileCheck ( '_global' , 'lan_global_list' , 'refresh' , $pluginDBList [ $plugin_path ][ 'plugin_installflag' ], TRUE , $plugin_path )) $sp = TRUE ;
2012-12-23 15:00:15 +00:00
}
2009-07-09 02:47:17 +00:00
2010-06-23 10:21:21 +00:00
// Check for missing plugin_category in plugin table.
if ( $pluginDBList [ $plugin_path ][ 'plugin_category' ] == '' || $pluginDBList [ $plugin_path ][ 'plugin_category' ] != $plug_info [ 'category' ])
2009-07-09 02:47:17 +00:00
{
2009-12-09 22:38:18 +00:00
// print_a($plug_info);
2010-06-23 10:21:21 +00:00
$pluginDBList [ $plugin_path ][ 'status' ] = 'update' ;
2015-02-14 23:34:15 -08:00
$pluginDBList [ $plugin_path ][ 'plugin_category' ] = ( vartrue ( $plug_info [ 'category' ])) ? $plug_info [ 'category' ] : " misc " ;
2009-07-09 02:47:17 +00:00
}
2008-01-20 15:01:19 +00:00
// If plugin not installed, and version number of files changed, update version as well
2008-12-03 22:29:58 +00:00
if (( $pluginDBList [ $plugin_path ][ 'plugin_installflag' ] == 0 ) && ( $pluginDBList [ $plugin_path ][ 'plugin_version' ] != $plug_info [ '@attributes' ][ 'version' ]))
2010-06-23 10:21:21 +00:00
{ // Update stored version
2008-12-03 22:29:58 +00:00
$pluginDBList [ $plugin_path ][ 'plugin_version' ] = $plug_info [ '@attributes' ][ 'version' ];
2008-01-20 15:01:19 +00:00
$pluginDBList [ $plugin_path ][ 'status' ] = 'update' ;
}
if ( $pluginDBList [ $plugin_path ][ 'plugin_addons' ] != $eplug_addons )
2010-06-23 10:21:21 +00:00
{ // Update stored addons list
2008-01-20 15:01:19 +00:00
$pluginDBList [ $plugin_path ][ 'plugin_addons' ] = $eplug_addons ;
$pluginDBList [ $plugin_path ][ 'status' ] = 'update' ;
}
2010-06-23 10:21:21 +00:00
if ( $pluginDBList [ $plugin_path ][ 'plugin_installflag' ] == 0 ) // Plugin not installed - make sure $pref not set
2009-12-09 22:38:18 +00:00
{
2010-06-23 10:21:21 +00:00
if ( isset ( $p_installed [ $plugin_path ]))
2008-01-20 15:01:19 +00:00
{
2009-09-03 22:27:32 +00:00
unset ( $p_installed [ $plugin_path ]);
2008-01-20 15:01:19 +00:00
$sp = TRUE ;
}
}
else
2010-06-23 10:21:21 +00:00
{ // Plugin installed - make sure $pref is set
2009-09-03 22:27:32 +00:00
if ( ! isset ( $p_installed [ $plugin_path ]) || ( $p_installed [ $plugin_path ] != $pluginDBList [ $plugin_path ][ 'plugin_version' ]))
2010-06-23 10:21:21 +00:00
{ // Update prefs array of installed plugins
2009-09-03 22:27:32 +00:00
$p_installed [ $plugin_path ] = $pluginDBList [ $plugin_path ][ 'plugin_version' ];
2008-01-20 15:01:19 +00:00
// echo "Add: ".$plugin_path."->".$ep_row['plugin_version']."<br />";
$sp = TRUE ;
}
}
2007-06-05 19:51:36 +00:00
}
2009-10-23 09:08:15 +00:00
else // New plugin - not in table yet, so add it. If no install needed, mark it as 'installed'
2009-12-09 22:38:18 +00:00
{
2008-12-05 14:18:51 +00:00
if ( $plug_info [ '@attributes' ][ 'name' ])
2012-08-22 02:45:32 +00:00
{
2012-12-05 16:43:53 -08:00
$pName = vartrue ( $plug_info [ '@attributes' ][ 'lan' ]) ? $plug_info [ '@attributes' ][ 'lan' ] : $plug_info [ '@attributes' ][ 'name' ] ;
2012-08-22 02:45:32 +00:00
2010-06-23 10:21:21 +00:00
$_installed = ( $plug_info [ '@attributes' ][ 'installRequired' ] == 'true' || $plug_info [ '@attributes' ][ 'installRequired' ] == 1 ? 0 : 1 );
2013-04-11 21:58:01 +02:00
2013-04-11 13:42:57 -07:00
$pInsert = array (
'plugin_id' => 0 ,
'plugin_name' => $tp -> toDB ( $pName , true ),
'plugin_version' => $tp -> toDB ( $plug_info [ '@attributes' ][ 'version' ], true ),
'plugin_path' => $tp -> toDB ( $plugin_path , true ),
'plugin_installflag' => $_installed ,
'plugin_addons' => $eplug_addons ,
'plugin_category' => $this -> manage_category ( $plug_info [ 'category' ])
);
// if (e107::getDb()->db_Insert("plugin", "0, '".$tp->toDB($pName, true)."', '".$tp->toDB($plug_info['@attributes']['version'], true)."', '".$tp->toDB($plugin_path, true)."',{$_installed}, '{$eplug_addons}', '".$this->manage_category($plug_info['category'])."' "))
if ( e107 :: getDb () -> insert ( " plugin " , $pInsert ))
{
2013-05-12 20:56:35 -07:00
$log -> addDebug ( " Added <b> " . $tp -> toHTML ( $pName , false , " defs " ) . " </b> to the plugin table. " );
2013-04-11 21:58:01 +02:00
}
else
{
2013-05-12 20:56:35 -07:00
$log -> addDebug ( " Failed to add " . $tp -> toHTML ( $pName , false , " defs " ) . " to the plugin table. " );
2013-04-11 21:58:01 +02:00
}
2013-05-12 20:56:35 -07:00
$log -> flushMessages ( " Updated Plugins table " );
2009-12-09 22:38:18 +00:00
}
2008-01-20 15:01:19 +00:00
}
2007-02-01 22:00:41 +00:00
}
2018-08-06 13:07:13 -07:00
// else
2010-06-23 10:21:21 +00:00
{ // May be useful that we ignore what will usually be copies/backups of plugins - but don't normally say anything
// echo "Plugin copied to wrong directory. Is in: {$plugin_path} Should be: {$plug_info['folder']}<br /><br />";
2007-02-01 22:00:41 +00:00
}
2009-07-09 02:47:17 +00:00
2010-06-23 10:21:21 +00:00
// print_a($plug_info);
2006-12-02 04:36:16 +00:00
}
2007-06-05 19:51:36 +00:00
// Now scan the table, updating the DB where needed
foreach ( $pluginDBList as $plug_path => $plug_info )
{
2008-01-20 15:01:19 +00:00
if ( $plug_info [ 'status' ] == 'read' )
2010-06-23 10:21:21 +00:00
{ // In table, not on server - delete it
2013-02-25 01:05:35 -08:00
$sql -> delete ( 'plugin' , " `plugin_id`= { $plug_info [ 'plugin_id' ] } " );
2008-01-20 15:01:19 +00:00
// echo "Deleted: ".$plug_path."<br />";
2010-06-23 10:21:21 +00:00
}
2008-01-20 15:01:19 +00:00
if ( $plug_info [ 'status' ] == 'update' )
2007-06-05 19:51:36 +00:00
{
2008-01-20 15:01:19 +00:00
$temp = array ();
foreach ( $this -> all_editable_db_fields as $p_f )
{
2010-06-23 10:21:21 +00:00
$temp [] = " ` { $p_f } ` = ' { $plug_info [ $p_f ] } ' " ;
2008-01-20 15:01:19 +00:00
}
2013-02-25 01:05:35 -08:00
$sql -> update ( 'plugin' , implode ( " , " , $temp ) . " WHERE `plugin_id`= { $plug_info [ 'plugin_id' ] } " );
2008-01-20 15:01:19 +00:00
// echo "Updated: ".$plug_path."<br />";
2010-06-23 10:21:21 +00:00
}
2006-12-02 04:36:16 +00:00
}
2012-01-06 09:49:08 +00:00
if ( $sp /* && vartrue($p_installed)*/ )
2009-09-03 22:27:32 +00:00
{
2010-06-23 10:21:21 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( 'plug_installed' , $p_installed );
2012-01-06 09:49:08 +00:00
$this -> rebuildUrlConfig ();
2016-11-01 12:12:00 -07:00
e107 :: getConfig ( 'core' ) -> save ( true , false , false );
2009-09-03 22:27:32 +00:00
}
2016-12-21 14:54:28 +01:00
// Triggering system (post) event.
e107 :: getEvent () -> trigger ( 'system_plugins_table_updated' , array (
'mode' => $mode ,
));
2006-12-02 04:36:16 +00:00
}
2009-12-09 22:38:18 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $cat
* @ return mixed | string
*/
2018-08-06 13:07:13 -07:00
private function manage_category ( $cat )
2009-09-14 11:27:45 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2010-06-23 10:21:21 +00:00
if ( vartrue ( $cat ) && in_array ( $cat , $this -> accepted_categories ))
2009-09-14 11:27:45 +00:00
{
return $cat ;
}
else
{
return 'misc' ;
}
}
2006-12-02 04:36:16 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $plugin
* @ param $function
* @ return void | null
*/
2018-08-06 13:07:13 -07:00
private function manage_icons ( $plugin = '' , $function = '' )
2009-07-16 02:55:19 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2010-06-23 10:21:21 +00:00
if ( $plugin == '' )
2010-03-14 02:11:23 +00:00
{
2018-08-05 15:08:54 -07:00
return null ;
2010-03-14 02:11:23 +00:00
}
2009-12-09 22:38:18 +00:00
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2010-03-14 02:11:23 +00:00
$med = e107 :: getMedia ();
2010-03-17 23:59:52 +00:00
2010-06-23 10:21:21 +00:00
if ( $function == 'install' || $function == 'upgrade' )
2009-09-28 07:17:52 +00:00
{
2010-06-23 10:21:21 +00:00
$med -> importIcons ( e_PLUGIN . $plugin );
2018-08-05 15:08:54 -07:00
return null ;
2009-09-28 07:17:52 +00:00
}
2010-03-17 23:59:52 +00:00
2010-06-23 10:21:21 +00:00
if ( $function == 'uninstall' )
2009-07-16 02:55:19 +00:00
{
2010-06-23 10:21:21 +00:00
if ( vartrue ( $this -> unInstallOpts [ 'delete_ipool' ], FALSE ))
2010-03-17 23:59:52 +00:00
{
2013-03-07 13:51:30 +02:00
$status = ( $med -> removePath ( e_PLUGIN . $plugin , 'icon' )) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-10-15 20:10:16 +02:00
$mes -> add ( IMALAN_164 , $status );
2017-01-26 15:37:42 -08:00
$this -> log ( " Deleted Icons from Media-Manager " ); // No LANS
2010-03-14 02:11:23 +00:00
}
2018-08-05 15:08:54 -07:00
return null ;
2010-03-17 23:59:52 +00:00
}
2007-05-07 13:38:34 +00:00
2009-07-16 02:55:19 +00:00
}
2007-05-07 13:38:34 +00:00
2006-12-02 04:36:16 +00:00
/**
2010-06-23 10:21:21 +00:00
* Returns details of a plugin from the plugin table from it ' s ID
2018-08-03 16:36:21 -07:00
* @ deprecated
* @ param int | string $id
2010-06-23 10:21:21 +00:00
* @ return array plugin info
*/
2018-07-22 09:36:23 -07:00
static function getPluginRecord ( $id )
2008-01-28 02:49:50 +00:00
{
2018-07-21 12:08:00 -05:00
2018-07-22 09:36:23 -07:00
$path = ( ! is_numeric ( $id )) ? $id : false ;
$id = ( int ) $id ;
2018-08-03 16:36:21 -07:00
if ( ! empty ( $path ))
{
// $bla = e107::getPlug()->load($path);
2018-08-05 15:08:54 -07:00
if ( $tmp = e107 :: getPlug () -> load ( $path ) -> getFields ( true ))
2018-08-03 16:36:21 -07:00
{
2018-08-05 15:08:54 -07:00
return $tmp ;
2018-08-03 16:36:21 -07:00
}
}
2018-08-06 13:07:13 -07:00
else // log all deprecated calls made using an integer so they can be removed in future.
{
$dbgArr = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 3 );
unset ( $dbgArr [ 0 ]);
e107 :: getLog () -> addDebug ( " Deprecated call to getPluginRecord() using integer. " . print_a ( $dbgArr , true ));
}
2018-08-03 16:36:21 -07:00
$sql = e107 :: getDb ();
$getinfo_results = array ();
2018-07-22 09:36:23 -07:00
$qry = " plugin_id = " . $id ;
$qry .= ( $path != false ) ? " OR plugin_path = ' " . $path . " ' " : " " ;
if ( $sql -> select ( 'plugin' , '*' , $qry )) {
$getinfo_results [ $id ] = $sql -> fetch ();
2018-07-21 12:23:44 -07:00
}
2018-07-22 09:36:23 -07:00
2008-01-28 02:49:50 +00:00
return $getinfo_results [ $id ];
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return void
*/
2018-08-06 13:07:13 -07:00
private function setUe ()
2008-11-24 00:36:50 +00:00
{
2010-06-23 10:21:21 +00:00
if ( ! isset ( $this -> module [ 'ue' ]))
2008-11-24 00:36:50 +00:00
{
include_once ( e_HANDLER . 'user_extended_class.php' );
$this -> module [ 'ue' ] = new e107_user_extended ;
}
2011-11-25 17:35:12 +00:00
}
/**
* User field name , based on its type
* @ param string $folder plugin folder
* @ param int $type normalized field type
* @ param string $name field name
* @ return string field name
*/
2018-08-06 13:07:13 -07:00
private function ue_field_name ( $folder , $type , $name )
2011-11-25 17:35:12 +00:00
{
if ( $type == EUF_PREFIELD || $type == EUF_CATEGORY )
{
return $name ; // no plugin_plugname_ prefix
}
return 'plugin_' . $folder . '_' . $name ;
}
/**
* Normalize type
* @ param array $attrib parsed from XML user field definitions
* @ return integer type ID
*/
2018-08-06 13:07:13 -07:00
private function ue_field_type ( $attrib )
2011-11-25 17:35:12 +00:00
{
$field_type = $attrib [ 'type' ];
2009-09-21 21:53:38 +00:00
$type = defined ( $field_type ) ? constant ( $field_type ) : $field_type ;
2011-11-25 17:35:12 +00:00
if ( ! is_numeric ( $type ))
{
// normalize further
$this -> setUe ();
$type = $this -> module [ 'ue' ] -> typeArray [ $type ];
}
return $type ;
}
/**
* Type number to type name
* @ param integer $typeId
* @ return string type name
*/
2018-08-06 13:07:13 -07:00
private function ue_field_type_name ( $typeId )
2011-11-25 17:35:12 +00:00
{
if ( is_numeric ( $typeId ))
{
$this -> setUe ();
return array_search ( $typeId , $this -> module [ 'ue' ] -> typeArray );
}
return $typeId ;
}
/**
2012-12-23 15:00:15 +00:00
* Field attributes ( $field_attrib array ) as they have to be defined in plugin . xml :
2011-11-25 17:35:12 +00:00
* name - REQUIRED string
* text - ( string | constant name ) field label
* type - REQUIRED ( constant name ) see EUF_ * constants in e107_user_extended class
* regex - regex validation string
* required - 0 - not requried , don ' t show on signup ; 1 - required , show on signup ; 2 - not required , show on signup
* allow_hide ( 0 | 1 ) - allow user to hide this field on profile page
* read , write , applicable - classes , see e_UC_ * defines
* values - comma separated values ( if required )
* default - default value
* order - ( number )
* parent - ( string ) category name for this field
* system - ( 0 | 1 ) - field wont be shown if it ' s system , NOTE - default value if system is not set is 1 !
*
* @ param string $action - add | remove
* @ param string $field_name normalized field name ( see self :: ue_field_name ())
* @ param array $field_attrib
* @ param string $field_source used for system user fields
2012-12-23 15:00:15 +00:00
*
2011-11-25 17:35:12 +00:00
* @ return boolean success
*/
2018-08-06 13:07:13 -07:00
private function manage_extended_field ( $action , $field_name , $field_attrib , $field_source = '' )
2011-11-25 17:35:12 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2011-11-25 17:35:12 +00:00
$mes = e107 :: getMessage ();
$this -> setUe ();
$type = $this -> ue_field_type ( $field_attrib );
$type_name = $this -> ue_field_type_name ( $type );
2013-02-27 15:18:48 +01:00
$mes -> addDebug ( " Extended Field: " . $action . " : " . $field_name . " : " . $type_name );
2016-04-02 12:47:27 -07:00
2011-11-25 17:35:12 +00:00
// predefined
if ( $type == EUF_PREFIELD )
{
$preList = $this -> module [ 'ue' ] -> parse_extended_xml ( '' ); // passed value currently not used at all, could be file path in the near future
if ( $preList && isset ( $preList [ $field_name ]))
{
$preField = $preList [ $field_name ];
if ( $preField )
{
$field_attrib = array_merge ( $preField , $field_attrib ); // merge
// predefined type - numeric value, constant or as defined in user_extended_class::typeArray
$field_attrib [ 'type' ] = $type = $this -> ue_field_type ( $preField ); // override type
}
else
{
return false ;
}
}
}
// not allowed for categories
elseif ( $type == EUF_CATEGORY )
{
$field_attrib [ 'parent' ] = 0 ;
}
2008-12-05 14:18:51 +00:00
2010-06-23 10:21:21 +00:00
if ( $action == 'add' )
2008-11-24 00:36:50 +00:00
{
2011-11-25 17:35:12 +00:00
// system field
if ( $field_attrib [ 'system' ])
{
return $this -> module [ 'ue' ] -> user_extended_add_system ( $field_name , $type , varset ( $field_attrib [ 'default' ], '' ), $field_source );
}
// new - add non-system extended field
// classes
$field_attrib [ 'read' ] = varset ( $field_attrib [ 'read' ], 'e_UC_MEMBER' );
$field_attrib [ 'write' ] = varset ( $field_attrib [ 'read' ], 'e_UC_MEMBER' );
$field_attrib [ 'applicable' ] = varset ( $field_attrib [ 'applicable' ], 'e_UC_MEMBER' );
// manage parent
2020-12-20 11:50:10 -08:00
if ( ! empty ( $field_attrib [ 'parent' ]))
2011-11-25 17:35:12 +00:00
{
foreach ( $this -> module [ 'ue' ] -> catDefinitions as $key => $value )
{
if ( $value [ 'user_extended_struct_name' ] == $field_attrib [ 'parent' ])
{
$field_attrib [ 'parent' ] = $key ;
break ;
}
}
if ( ! is_numeric ( $field_attrib [ 'parent' ])) $field_attrib [ 'parent' ] = 0 ;
}
else $field_attrib [ 'parent' ] = 0 ;
// manage required (0, 1, 2)
if ( ! isset ( $field_attrib [ 'required' ]))
{
$field_attrib [ 'required' ] = 0 ;
}
// manage params
$field_attrib [ 'parms' ] = '' ;
// validation and parms
$include = varset ( $field_attrib [ 'include_text' ]);
$regex = varset ( $field_attrib [ 'regex' ]);
$hide = vartrue ( $field_attrib [ 'allow_hide' ]) ? 1 : 0 ;
$failmsg = '' ;
2012-01-11 16:12:01 +00:00
if ( $regex || $hide )
2011-11-25 17:35:12 +00:00
{
// failmsg only when required
if ( $field_attrib [ 'required' ] == 1 || $regex )
$failmsg = vartrue ( $field_attrib [ 'error' ]) ? $field_attrib [ 'error' ] : 'LAN_UE_FAIL_' . strtoupper ( $field_name );
$field_attrib [ 'parms' ] = $include . " ^,^ " . $regex . " ^,^ " . $failmsg . '^,^' . $hide ;
}
//var_dump($field_attrib, $field_name, $type);
2016-04-02 12:47:27 -07:00
$mes -> addDebug ( " Extended Field: " . print_a ( $field_attrib , true ));
2011-11-25 17:35:12 +00:00
$status = $this -> module [ 'ue' ] -> user_extended_add (
$field_name ,
varset ( $field_attrib [ 'text' ], " LAN_UE_ " . strtoupper ( $field_name )),
$type ,
$field_attrib [ 'parms' ],
varset ( $field_attrib [ 'values' ], '' ),
varset ( $field_attrib [ 'default' ], '' ),
$field_attrib [ 'required' ],
defset ( $field_attrib [ 'read' ], e_UC_MEMBER ),
defset ( $field_attrib [ 'write' ], e_UC_MEMBER ),
defset ( $field_attrib [ 'applicable' ], e_UC_MEMBER ),
varset ( $field_attrib [ 'order' ], '' ),
$field_attrib [ 'parent' ]
);
// db fields handling
if ( $status && $type == EUF_DB_FIELD )
{
// handle DB, use original non-modified name value
$status = ! $this -> manage_extended_field_sql ( 'add' , $field_attrib [ 'name' ]); // reverse logic - sql method do a error check
}
// refresh categories - sadly the best way so far... need improvement (inside ue class)
if ( $status && $type == EUF_CATEGORY )
{
$cats = $this -> module [ 'ue' ] -> user_extended_get_categories ( false );
foreach ( $cats as $cat )
{
$this -> module [ 'ue' ] -> catDefinitions [ $cat [ 'user_extended_struct_id' ]] = $cat ;
}
}
return $status ;
2008-11-24 00:36:50 +00:00
}
2008-12-05 14:18:51 +00:00
2008-11-24 00:36:50 +00:00
if ( $action == 'remove' )
{
2011-11-25 17:35:12 +00:00
//var_dump($field_attrib, $field_name, $type);
$status = $this -> module [ 'ue' ] -> user_extended_remove ( $field_name , $field_name );
if ( $status && $type == EUF_DB_FIELD )
{
$status = $this -> manage_extended_field_sql ( 'remove' , $field_attrib [ 'name' ]);
}
return $status ;
}
return false ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $field_name
* @ return bool | void
*/
2018-08-06 13:07:13 -07:00
private function manage_extended_field_sql ( $action , $field_name )
2011-11-25 17:35:12 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2013-01-23 13:38:21 -08:00
$f = e_CORE . 'sql/extended_' . preg_replace ( '/[^\w]/' , '' , $field_name ) . '.php' ; // quick security, always good idea
2011-11-25 17:35:12 +00:00
if ( ! is_readable ( $f )) return false ;
// TODO - taken from user_extended Administration, need to be refined :/
// FIXME - use sql parse handler
$error = FALSE ;
$count = 0 ;
2016-05-05 18:51:30 -07:00
$sql = e107 :: getDb ();
2011-11-25 17:35:12 +00:00
if ( $action == 'add' )
{
$sql_data = file_get_contents ( $f );
$search [ 0 ] = " CREATE TABLE " ; $replace [ 0 ] = " CREATE TABLE " . MPREFIX ;
$search [ 1 ] = " INSERT INTO " ; $replace [ 1 ] = " INSERT INTO " . MPREFIX ;
preg_match_all ( " /create(.*?)myisam;/si " , $sql_data , $creation );
foreach ( $creation [ 0 ] as $tab )
{
$query = str_replace ( $search , $replace , $tab );
2016-05-05 18:51:30 -07:00
if ( ! $sql -> gen ( $query ))
2011-11-25 17:35:12 +00:00
{
$error = TRUE ;
}
$count ++ ;
}
preg_match_all ( " /insert(.*?);/si " , $sql_data , $inserts );
foreach ( $inserts [ 0 ] as $ins )
{
$qry = str_replace ( $search , $replace , $ins );
2016-05-05 18:51:30 -07:00
if ( ! $sql -> gen ( $qry ))
2011-11-25 17:35:12 +00:00
{
$error = TRUE ;
}
$count ++ ;
}
if ( ! $count ) $error = TRUE ;
return $error ;
}
//remove
if ( $action == 'remove' )
{
// executed only if the sql file exists!
2016-05-05 18:51:30 -07:00
return $sql -> gen ( " DROP TABLE " . MPREFIX . " user_extended_ " . $field_name ) ? true : false ;
2008-11-24 00:36:50 +00:00
}
}
2008-08-09 16:49:58 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $class_name
* @ param $class_description
* @ return bool | null
*/
2018-08-06 13:07:13 -07:00
private function manage_userclass ( $action , $class_name , $class_description = '' )
2008-01-20 15:01:19 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2018-07-22 09:36:23 -07:00
$e107 = e107 :: getInstance ();
2009-09-03 22:27:32 +00:00
$tp = e107 :: getParser ();
2010-06-23 10:21:21 +00:00
$sql = e107 :: getDb ();
2009-11-07 02:28:59 +00:00
$mes = e107 :: getMessage ();
2013-02-27 15:18:48 +01:00
$mes -> addDebug ( " Userclass: " . $action . " : " . $class_name . " : " . $class_description );
2009-12-09 22:38:18 +00:00
2010-03-17 23:59:52 +00:00
if ( ! $e107 -> user_class -> isAdmin ())
2008-12-29 22:30:16 +00:00
{
2010-06-23 10:21:21 +00:00
$e107 -> user_class = new user_class_admin ; // We need the extra methods of the admin extension
2018-08-06 13:07:13 -07:00
}
2008-12-29 22:30:16 +00:00
$class_name = strip_tags ( strtoupper ( $class_name ));
2008-01-20 15:01:19 +00:00
if ( $action == 'add' )
{
2008-12-29 20:55:27 +00:00
if ( $e107 -> user_class -> ucGetClassIDFromName ( $class_name ) !== FALSE )
2010-06-23 10:21:21 +00:00
{ // Class already exists.
return TRUE ; // That's probably OK
2013-02-27 15:18:48 +01:00
}
2008-12-29 22:30:16 +00:00
$i = $e107 -> user_class -> findNewClassID ();
if ( $i !== FALSE )
2008-01-20 15:01:19 +00:00
{
2008-12-10 13:27:09 +00:00
$tmp = array ();
$tmp [ 'userclass_id' ] = $i ;
2008-12-29 20:55:27 +00:00
$tmp [ 'userclass_name' ] = $class_name ;
2008-12-10 13:27:09 +00:00
$tmp [ 'userclass_description' ] = $class_description ;
2008-12-21 01:57:19 +00:00
$tmp [ 'userclass_editclass' ] = e_UC_ADMIN ;
$tmp [ 'userclass_visibility' ] = e_UC_ADMIN ;
2008-12-29 20:55:27 +00:00
$tmp [ 'userclass_type' ] = UC_TYPE_STD ;
$tmp [ 'userclass_parent' ] = e_UC_NOBODY ;
2008-12-21 01:57:19 +00:00
$tmp [ '_FIELD_TYPES' ][ 'userclass_editclass' ] = 'int' ;
$tmp [ '_FIELD_TYPES' ][ 'userclass_visibility' ] = 'int' ;
2008-12-10 13:27:09 +00:00
$tmp [ '_FIELD_TYPES' ][ 'userclass_id' ] = 'int' ;
$tmp [ '_FIELD_TYPES' ][ '_DEFAULT' ] = 'todb' ;
2008-12-29 22:30:16 +00:00
return $e107 -> user_class -> add_new_class ( $tmp );
2008-01-20 15:01:19 +00:00
}
else
{
2012-11-07 20:27:41 +00:00
return NULL ;
2006-12-02 04:36:16 +00:00
}
}
2008-01-20 15:01:19 +00:00
if ( $action == 'remove' )
{
2008-12-29 22:30:16 +00:00
$classID = $e107 -> user_class -> ucGetClassIDFromName ( $class_name );
2010-06-23 10:21:21 +00:00
if (( $classID !== FALSE ) && ( $e107 -> user_class -> deleteClassAndUsers ( $classID ) === TRUE ))
2008-01-20 15:01:19 +00:00
{
2008-12-29 22:30:16 +00:00
return TRUE ;
}
else
{
return FALSE ;
2006-12-02 04:36:16 +00:00
}
}
2018-08-06 13:07:13 -07:00
return null ;
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $link_url
* @ param $link_name
* @ param $link_class
* @ param $options
* @ return int | void | null
*/
2018-08-06 13:07:13 -07:00
private function manage_link ( $action , $link_url , $link_name , $link_class = 0 , $options = array ())
2008-01-20 15:01:19 +00:00
{
2009-12-09 22:38:18 +00:00
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2012-12-12 18:46:34 -08:00
2010-06-23 10:21:21 +00:00
if ( ! is_numeric ( $link_class ))
2008-01-27 01:34:59 +00:00
{
$link_class = strtolower ( $link_class );
$plug_perm [ 'everyone' ] = e_UC_PUBLIC ;
$plug_perm [ 'guest' ] = e_UC_GUEST ;
$plug_perm [ 'member' ] = e_UC_MEMBER ;
$plug_perm [ 'mainadmin' ] = e_UC_MAINADMIN ;
$plug_perm [ 'admin' ] = e_UC_ADMIN ;
$plug_perm [ 'nobody' ] = e_UC_NOBODY ;
2012-12-12 18:46:34 -08:00
$link_class = ( $plug_perm [ $link_class ]) ? intval ( $plug_perm [ $link_class ]) : e_UC_PUBLIC ;
2008-01-27 01:34:59 +00:00
}
2012-12-12 18:46:34 -08:00
2010-06-23 10:21:21 +00:00
$link_url = $tp -> toDB ( $link_url , true );
$link_name = $tp -> toDB ( $link_name , true );
$path = str_replace ( " ../ " , " " , $link_url ); // This should clean up 'non-standard' links
2012-12-12 21:30:43 -08:00
$path = $tp -> createConstants ( $path ); // Add in standard {e_XXXX} directory constants if we can
2008-01-20 15:01:19 +00:00
if ( $action == 'add' )
2007-05-30 20:35:44 +00:00
{
2013-02-25 01:05:35 -08:00
$link_t = $sql -> count ( 'links' );
2021-01-17 20:31:25 -08:00
$countQry = ! empty ( $options [ 'link_owner' ]) ? " link_owner = ' " . $options [ 'link_owner' ] . " ' AND link_url = ' " . $path . " ' " : " link_url = ' { $path } ' OR link_name = ' " . $link_name . " ' " ;
if ( ! $sql -> count ( 'links' , '(*)' , " WHERE " . $countQry ))
2007-09-28 20:00:37 +00:00
{
2010-06-23 10:21:21 +00:00
$linkData = array (
'link_name' => $link_name ,
'link_url' => $path ,
2015-06-10 14:22:59 -07:00
'link_description' => vartrue ( $options [ 'link_desription' ], '' ),
'link_button' => vartrue ( $options [ 'link_icon' ], '' ),
2010-06-23 10:21:21 +00:00
'link_category' => '1' ,
'link_order' => $link_t + 1 ,
'link_parent' => '0' ,
'link_open' => '0' ,
2015-06-10 15:01:14 -07:00
'link_class' => vartrue ( $link_class , '0' ),
2018-09-18 09:38:34 -07:00
'link_function' => vartrue ( $options [ 'link_function' ]),
2015-06-10 14:22:59 -07:00
'link_sefurl' => vartrue ( $options [ 'link_sef' ]),
2015-02-06 00:14:55 -08:00
'link_owner' => vartrue ( $options [ 'link_owner' ])
2009-12-11 21:17:09 +00:00
);
2015-02-06 00:14:55 -08:00
return $sql -> insert ( 'links' , $linkData );
2008-01-20 15:01:19 +00:00
}
else
2007-09-28 20:00:37 +00:00
{
2021-01-17 20:31:25 -08:00
e107 :: getMessage () -> addDebug ( " Skipped inserting of sitelink. Count Qry: " . $countQry );
2018-09-18 09:38:34 -07:00
return null ;
2006-12-02 04:36:16 +00:00
}
}
2015-02-06 00:14:55 -08:00
if ( $action == 'remove' )
{
//v2.x
2020-12-20 11:50:10 -08:00
if ( ! empty ( $options [ 'link_owner' ]) && $sql -> select ( 'links' , 'link_id' , " link_owner = ' " . $options [ 'link_owner' ] . " ' " ))
2015-02-06 00:14:55 -08:00
{
return $sql -> delete ( 'links' , " link_owner = ' " . $options [ 'link_owner' ] . " ' " );
}
// Look up by URL if we can - should be more reliable. Otherwise try looking up by name (as previously)
2013-02-25 01:05:35 -08:00
if (( $path && $sql -> select ( 'links' , 'link_id,link_order' , " link_url = ' { $path } ' " )) || $sql -> select ( 'links' , 'link_id,link_order' , " link_name = ' { $link_name } ' " ))
2008-01-20 15:01:19 +00:00
{
2013-02-25 01:05:35 -08:00
$row = $sql -> fetch ();
2020-12-14 16:21:48 -08:00
$sql -> update ( 'links' , " link_order = link_order - 1 WHERE link_order > { $row [ 'link_order' ] } " );
2013-02-25 01:05:35 -08:00
return $sql -> delete ( 'links' , " link_id = { $row [ 'link_id' ] } " );
2008-01-20 15:01:19 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
2018-08-05 15:08:54 -07:00
// DEPRECATED in 0.8 -
2008-08-09 16:49:58 +00:00
// Update prefs array according to $action
// $prefType specifies the storage type - may be 'pref', 'listPref' or 'arrayPref'
2018-08-05 15:08:54 -07:00
/**
2020-12-18 09:39:02 -08:00
* @ outdated See XmlPrefs (); Left for BC .
2018-08-05 15:08:54 -07:00
* @ param $action
* @ param $var
* @ param string $prefType
* @ param string $path
* @ param bool $unEscape
* @ return null | void
*/
2008-08-11 20:21:17 +00:00
function manage_prefs ( $action , $var , $prefType = 'pref' , $path = '' , $unEscape = FALSE )
2008-01-20 15:01:19 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2010-06-23 10:21:21 +00:00
global $pref ;
if ( ! is_array ( $var ))
2018-08-05 15:08:54 -07:00
return null ;
2010-06-23 10:21:21 +00:00
if (( $prefType == 'arrayPref' ) && ( $path == '' ))
2018-08-05 15:08:54 -07:00
return null ;
2010-06-23 10:21:21 +00:00
foreach ( $var as $k => $v )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
if ( $unEscape )
2008-08-09 16:49:58 +00:00
{
2010-06-23 10:21:21 +00:00
$v = str_replace ( array ( '\{' , '\}' ), array ( '{' , '}' ), $v );
2008-08-09 16:49:58 +00:00
}
2010-06-23 10:21:21 +00:00
switch ( $prefType )
2008-08-09 16:49:58 +00:00
{
2010-06-23 10:21:21 +00:00
case 'pref' :
switch ( $action )
{
case 'add' :
$pref [ $k ] = $v ;
break ;
2012-12-23 15:00:15 +00:00
case 'update' :
case 'upgrade' :
2010-06-23 10:21:21 +00:00
case 'refresh' :
// Only update if $pref doesn't exist
if ( ! isset ( $pref [ $k ]))
$pref [ $k ] = $v ;
break ;
case 'remove' :
if ( is_numeric ( $k ))
{ // Sometimes arrays specified with value being the name of the key to delete
unset ( $pref [ $var [ $k ]]);
}
else
{ // This is how the array should be specified - key is the name of the pref
unset ( $pref [ $k ]);
}
break ;
}
break ;
case 'listPref' :
$tmp = array ();
if ( isset ( $pref [ $k ]))
$tmp = explode ( ',' , $pref [ $k ]);
switch ( $action )
{
case 'add' :
2012-12-23 15:00:15 +00:00
case 'update' :
case 'upgrade' :
2010-06-23 10:21:21 +00:00
case 'refresh' :
if ( ! in_array ( $v , $tmp ))
$tmp [] = $v ;
break ;
case 'remove' :
if (( $tkey = array_search ( $v , $tmp )) !== FALSE )
unset ( $tmp [ $tkey ]);
break ;
}
$pref [ $k ] = implode ( ',' , $tmp ); // Leaves an empty element if no values - probably acceptable or even preferable
break ;
case 'arrayPref' :
switch ( $action )
{
case 'add' :
$pref [ $k ][ $path ] = $v ;
break ;
2012-12-23 15:00:15 +00:00
case 'update' :
case 'upgrade' :
2010-06-23 10:21:21 +00:00
case 'refresh' :
if ( ! isset ( $pref [ $k ][ $path ]))
$pref [ $k ][ $path ] = $v ;
break ;
case 'remove' :
if ( isset ( $pref [ $k ][ $path ]))
unset ( $pref [ $k ][ $path ]); // Leaves an empty element if no values - probably acceptable or even preferable
break ;
}
break ;
2008-08-09 16:49:58 +00:00
}
2006-12-02 04:36:16 +00:00
}
2009-12-09 22:38:18 +00:00
2016-11-01 12:12:00 -07:00
e107 :: getConfig ( 'core' ) -> setPref ( $pref ) -> save ( true , false , false );
2009-12-09 22:38:18 +00:00
2018-08-05 15:08:54 -07:00
return null ;
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $comment_id
* @ return int | void
*/
2008-02-02 22:04:18 +00:00
function manage_comments ( $action , $comment_id )
2008-01-20 15:01:19 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2009-12-09 22:38:18 +00:00
2008-02-02 22:04:18 +00:00
$tmp = array ();
2010-06-23 10:21:21 +00:00
if ( $action == 'remove' )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
foreach ( $comment_id as $com )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$tmp [] = " comment_type=' " . $tp -> toDB ( $com , true ) . " ' " ;
2006-12-02 04:36:16 +00:00
}
2010-06-23 10:21:21 +00:00
$qry = implode ( " OR " , $tmp );
// echo $qry."<br />";
2013-02-25 01:05:35 -08:00
return $sql -> delete ( 'comments' , $qry );
2008-01-20 15:01:19 +00:00
}
2006-12-02 04:36:16 +00:00
}
2008-08-12 20:26:53 +00:00
// Handle table updates - passed an array of actions.
// $var array:
// For 'add' - its a query to create the table
2008-12-10 22:39:43 +00:00
// For 'upgrade' - its a query to modify the table (not called from the plugin.xml handler)
2008-08-12 20:26:53 +00:00
// For 'remove' - its a table name
// 'upgrade' and 'remove' operate on all language variants of the same table
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $var
* @ return bool | string
*/
2008-01-20 15:01:19 +00:00
function manage_tables ( $action , $var )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2020-08-11 08:30:00 -07:00
$sql = e107 :: getDb ();
2012-12-04 00:13:49 -08:00
$mes = e107 :: getMessage ();
2010-06-23 10:21:21 +00:00
if ( ! is_array ( $var ))
return FALSE ; // Return if nothing to do
$error = false ;
$error_data = array ();
switch ( $action )
{
case 'add' :
foreach ( $var as $tab )
2008-01-20 15:01:19 +00:00
{
2013-04-17 14:07:45 -07:00
$tab = str_replace ( " TYPE=MyISAM " , " ENGINE=MyISAM " , $tab );
2015-04-23 10:04:23 -07:00
$tab = str_replace ( " IF NOT EXISTS " , " " , $tab );
2012-12-04 00:13:49 -08:00
if ( ! preg_match ( " /MyISAM.*CHARSET ?= ?utf8/i " , $tab ))
{
$tab = str_replace ( " MyISAM " , " MyISAM DEFAULT CHARSET=utf8 " , $tab );
}
2013-04-17 14:07:45 -07:00
2012-12-04 00:13:49 -08:00
$mes -> addDebug ( $tab );
2010-06-23 10:21:21 +00:00
if ( false === $sql -> db_Query ( $tab ))
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$error = true ;
$error_data [] = $tab ;
2006-12-02 04:36:16 +00:00
}
}
2010-06-23 10:21:21 +00:00
break ;
case 'upgrade' :
foreach ( $var as $tab )
{
if ( false === $sql -> db_Query_all ( $tab ))
{
$error = true ;
$error_data [] = $tab ;
}
}
break ;
case 'remove' :
foreach ( $var as $tab )
2008-01-20 15:01:19 +00:00
{
2006-12-02 04:36:16 +00:00
$qry = 'DROP TABLE ' . MPREFIX . $tab ;
2008-01-20 15:01:19 +00:00
if ( ! $sql -> db_Query_all ( $qry ))
{
2010-06-23 10:21:21 +00:00
$error = true ;
$error_data [] = $tab ;
2006-12-02 04:36:16 +00:00
}
}
2010-06-23 10:21:21 +00:00
break ;
}
// doesn't exit the loop now, returns true on success
// or error queries (string)
return ( ! $error ? true : ( ! empty ( $$error_data ) ? implode ( '<br />' , $error_data ) : false ));
2006-12-02 04:36:16 +00:00
}
2009-09-23 23:18:18 +00:00
// DEPRECATED for 0.8 xml files - See XmlPrefs();
2008-08-09 16:49:58 +00:00
// Handle prefs from arrays (mostly 0.7 stuff, possibly apart from the special cases)
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $prefname
* @ param $plugin_folder
* @ param $varArray
* @ return void
*/
2008-01-20 15:01:19 +00:00
function manage_plugin_prefs ( $action , $prefname , $plugin_folder , $varArray = '' )
2010-06-23 10:21:21 +00:00
{ // These prefs are 'cumulative' - several plugins may contribute an array element
// global $pref;
/*
if ( $prefname == 'plug_sc' || $prefname == 'plug_bb' )
{ // Special cases - shortcodes and bbcodes - each plugin may contribute several elements
foreach ( $varArray as $code )
{
$prefvals [] = " $code : $plugin_folder " ;
}
}
else
{
*/
2018-08-03 12:22:17 -07:00
$pref = e107 :: getPref ();
2010-06-23 10:21:21 +00:00
$prefvals [] = $varArray ;
// $prefvals[] = $plugin_folder;
// }
2006-12-02 04:36:16 +00:00
$curvals = explode ( ',' , $pref [ $prefname ]);
2008-01-20 15:01:19 +00:00
if ( $action == 'add' )
2007-02-01 22:00:41 +00:00
{
2006-12-02 04:36:16 +00:00
$newvals = array_merge ( $curvals , $prefvals );
}
2008-01-20 15:01:19 +00:00
if ( $action == 'remove' )
2007-02-01 22:00:41 +00:00
{
2010-06-23 10:21:21 +00:00
foreach ( $prefvals as $v )
2007-02-01 22:00:41 +00:00
{
2008-01-20 15:01:19 +00:00
if (( $i = array_search ( $v , $curvals )) !== FALSE )
{
unset ( $curvals [ $i ]);
}
2006-12-02 04:36:16 +00:00
}
2008-01-20 15:01:19 +00:00
$newvals = $curvals ;
2006-12-02 04:36:16 +00:00
}
$newvals = array_unique ( $newvals );
2007-02-01 22:00:41 +00:00
$pref [ $prefname ] = implode ( ',' , $newvals );
2021-01-24 17:00:02 -08:00
if ( strpos ( $pref [ $prefname ], " , " ) === 0 )
2006-12-02 04:36:16 +00:00
{
2008-01-20 15:01:19 +00:00
$pref [ $prefname ] = substr ( $pref [ $prefname ], 1 );
2006-12-02 04:36:16 +00:00
}
2009-12-09 22:38:18 +00:00
2009-09-06 20:04:04 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( $pref );
2016-11-01 12:12:00 -07:00
e107 :: getConfig ( 'core' ) -> save ( true , false , false );
2009-09-26 16:54:21 +00:00
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $eplug_folder
* @ return void
*/
2008-01-20 15:01:19 +00:00
function manage_search ( $action , $eplug_folder )
{
2009-09-03 22:27:32 +00:00
global $sysprefs ;
$sql = e107 :: getDb ();
2009-12-09 22:38:18 +00:00
2009-09-14 11:27:45 +00:00
$search_prefs = e107 :: getConfig ( 'search' ) -> getPref ();
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
// $search_prefs = $sysprefs -> getArray('search_prefs');
2006-12-02 04:36:16 +00:00
$default = file_exists ( e_PLUGIN . $eplug_folder . '/e_search.php' ) ? TRUE : FALSE ;
$comments = file_exists ( e_PLUGIN . $eplug_folder . '/search/search_comments.php' ) ? TRUE : FALSE ;
2008-01-20 15:01:19 +00:00
if ( $action == 'add' )
{
2006-12-02 04:36:16 +00:00
$install_default = $default ? TRUE : FALSE ;
$install_comments = $comments ? TRUE : FALSE ;
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
if ( $action == 'remove' )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$uninstall_default = isset ( $search_prefs [ 'plug_handlers' ][ $eplug_folder ]) ? TRUE : FALSE ;
$uninstall_comments = isset ( $search_prefs [ 'comments_handlers' ][ $eplug_folder ]) ? TRUE : FALSE ;
2008-01-20 15:01:19 +00:00
}
else
2010-06-23 10:21:21 +00:00
if ( $action == 'upgrade' )
{
if ( isset ( $search_prefs [ 'plug_handlers' ][ $eplug_folder ]))
{
$uninstall_default = $default ? FALSE : TRUE ;
}
else
{
$install_default = $default ? TRUE : FALSE ;
}
if ( isset ( $search_prefs [ 'comments_handlers' ][ $eplug_folder ]))
{
$uninstall_comments = $comments ? FALSE : TRUE ;
}
else
{
$install_comments = $comments ? TRUE : FALSE ;
}
}
2009-09-03 22:27:32 +00:00
if ( vartrue ( $install_default ))
2008-01-20 15:01:19 +00:00
{
2006-12-02 04:36:16 +00:00
$search_prefs [ 'plug_handlers' ][ $eplug_folder ] = array ( 'class' => 0 , 'pre_title' => 1 , 'pre_title_alt' => '' , 'chars' => 150 , 'results' => 10 );
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
if ( vartrue ( $uninstall_default ))
{
unset ( $search_prefs [ 'plug_handlers' ][ $eplug_folder ]);
}
2009-09-03 22:27:32 +00:00
if ( vartrue ( $install_comments ))
2008-01-20 15:01:19 +00:00
{
2018-08-03 16:36:21 -07:00
$comments_type_id = '' ;
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . $eplug_folder . '/search/search_comments.php' );
$search_prefs [ 'comments_handlers' ][ $eplug_folder ] = array ( 'id' => $comments_type_id , 'class' => 0 , 'dir' => $eplug_folder );
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
if ( vartrue ( $uninstall_comments ))
{
unset ( $search_prefs [ 'comments_handlers' ][ $eplug_folder ]);
}
2009-12-09 22:38:18 +00:00
2016-11-01 12:12:00 -07:00
// e107::getConfig('search')->setPref($search_prefs)->save(true,false,false);
2009-12-09 22:38:18 +00:00
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ param $action
* @ param $eplug_folder
* @ return void
*/
2008-01-20 15:01:19 +00:00
function manage_notify ( $action , $eplug_folder )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-09-03 22:27:32 +00:00
$tp = e107 :: getParser ();
2010-06-23 10:21:21 +00:00
// $notify_prefs = $sysprefs -> get('notify_prefs');
// $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
2009-12-09 22:38:18 +00:00
2009-09-03 22:27:32 +00:00
$notify_prefs = e107 :: getConfig ( 'notify' );
2006-12-02 04:36:16 +00:00
$e_notify = file_exists ( e_PLUGIN . $eplug_folder . '/e_notify.php' ) ? TRUE : FALSE ;
2008-01-20 15:01:19 +00:00
if ( $action == 'add' )
{
2006-12-02 04:36:16 +00:00
$install_notify = $e_notify ? TRUE : FALSE ;
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
if ( $action == 'remove' )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$uninstall_notify = $notify_prefs -> isData ( 'plugins/' . $eplug_folder ); //isset($notify_prefs['plugins'][$eplug_folder]) ? TRUE : FALSE;
}
2008-01-20 15:01:19 +00:00
else
2010-06-23 10:21:21 +00:00
if ( $action == 'upgrade' )
{
if ( $notify_prefs -> isData ( 'plugins/' . $eplug_folder ))
{
$uninstall_notify = $e_notify ? FALSE : TRUE ;
}
else
{
$install_notify = $e_notify ? TRUE : FALSE ;
}
}
2018-08-03 12:22:17 -07:00
$config_events = array (); // Notice removal
2009-09-03 22:27:32 +00:00
if ( vartrue ( $install_notify ))
2008-01-20 15:01:19 +00:00
{
2009-09-15 16:10:32 +00:00
$notify_prefs -> setPref ( 'plugins/' . $eplug_folder , 1 ); //$notify_prefs['plugins'][$eplug_folder] = TRUE;
2018-08-03 12:22:17 -07:00
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . $eplug_folder . '/e_notify.php' );
2008-01-20 15:01:19 +00:00
foreach ( $config_events as $event_id => $event_text )
{
2009-09-15 16:10:32 +00:00
$notify_prefs -> setPref ( 'event/' . $event_id . '/class' , e_UC_NOBODY )
-> setPref ( 'event/' . $event_id . '/email' , '' );
//$notify_prefs['event'][$event_id] = array('class' => e_UC_NOBODY, 'email' => '');
2010-06-23 10:21:21 +00:00
}
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
if ( vartrue ( $uninstall_notify ))
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$notify_prefs -> removePref ( 'plugins/' . $eplug_folder );
//unset($notify_prefs['plugins'][$eplug_folder]);
require_once ( e_PLUGIN . $eplug_folder . '/e_notify.php' );
foreach ( $config_events as $event_id => $event_text )
{
$notify_prefs -> removePref ( 'event/' . $event_id );
//unset($notify_prefs['event'][$event_id]);
}
2006-12-02 04:36:16 +00:00
}
2009-09-15 16:10:32 +00:00
//$s_prefs = $tp -> toDB($notify_prefs);
2009-12-09 22:38:18 +00:00
//$s_prefs = e107::getArrayStorage()->WriteArray($s_prefs);
2009-09-15 16:10:32 +00:00
//e107::getDb() -> db_Update("core", "e107_value='".$s_prefs."' WHERE e107_name='notify_prefs'");
2016-11-01 12:12:00 -07:00
$notify_prefs -> save ( false , false , false );
2006-12-02 04:36:16 +00:00
}
2012-01-06 09:49:08 +00:00
/**
* Rebuild URL configuration values
* Note - new core system pref values will be set , but not saved
* e107 :: getConfig () -> save () is required outside after execution of this method
* @ return void
*/
public function rebuildUrlConfig ()
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2012-01-06 09:49:08 +00:00
$modules = eRouter :: adminReadModules (); // get all available locations, non installed plugins will be ignored
$config = eRouter :: adminBuildConfig ( e107 :: getPref ( 'url_config' ), $modules ); // merge with current config
$locations = eRouter :: adminBuildLocations ( $modules ); // rebuild locations pref
$aliases = eRouter :: adminSyncAliases ( e107 :: getPref ( 'url_aliases' ), $config ); // rebuild aliases
// set new values, changes should be saved outside this methods
2016-11-01 12:12:00 -07:00
/* e107 :: getConfig ()
2012-01-06 09:49:08 +00:00
-> set ( 'url_aliases' , $aliases )
-> set ( 'url_config' , $config )
-> set ( 'url_modules' , $modules )
-> set ( 'url_locations' , $locations );
2016-11-01 12:12:00 -07:00
*/
2012-01-06 09:49:08 +00:00
eRouter :: clearCache ();
}
2022-04-04 10:54:24 -07:00
/**
* @ param $array
* @ param $msg
* @ return string
*/
2010-06-23 10:21:21 +00:00
function displayArray ( & $array , $msg = '' )
2008-12-13 18:43:46 +00:00
{
$txt = ( $msg ? $msg . '<br />' : '' );
2010-06-23 10:21:21 +00:00
foreach ( $array as $_k => $_v )
2008-12-13 18:43:46 +00:00
{
$txt .= " { $_k } -> { $_v } <br /> " ;
}
2010-06-23 10:21:21 +00:00
$txt .= '<br />' ;
2008-12-13 18:43:46 +00:00
return $txt ;
}
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $message
* @ return void
*/
2017-01-26 15:37:42 -08:00
private function log ( $message )
{
$this -> log [] = $message ;
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2017-01-26 15:37:42 -08:00
public function getLog ()
{
$text = $this -> log ;
$this -> log = array ();
return $text ;
}
2009-10-30 09:13:37 +00:00
/**
* Install routine for XML file
2015-10-02 13:40:44 +03:00
* @ param mixed $id ( the number of the plugin in the DB ) or the path to the plugin folder . eg . 'forum'
* @ param string $function install | upgrade | uninstall | refresh ( adds things that are missing , but doesn ' t change any existing settings )
* @ param array $options [ optional ] an array of possible options - ATM used only for uninstall :
2009-10-30 09:13:37 +00:00
* 'delete_userclasses' - to delete userclasses created
* 'delete_tables' - to delete DB tables
* 'delete_xfields' - to delete extended fields
* 'delete_ipool' - to delete icon pool entry
2009-12-09 22:38:18 +00:00
* + any defined in < pluginname > _setup . php in the uninstall_options () method .
2017-01-26 15:37:42 -08:00
* @ return bool
2009-10-30 09:13:37 +00:00
*/
2015-10-02 13:40:44 +03:00
function install_plugin_xml ( $id , $function = '' , $options = null )
2012-12-08 00:36:34 -08:00
{
2014-01-20 06:20:58 -08:00
2012-12-08 00:36:34 -08:00
$pref = e107 :: getPref ();
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
2012-11-06 11:07:47 +00:00
$mes = e107 :: getMessage ();
2015-03-24 12:29:26 +01:00
$event = e107 :: getEvent ();
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
$this -> log ( " Running Plugin: " . $function );
2016-04-30 12:02:02 -07:00
2010-06-23 10:21:21 +00:00
$error = array (); // Array of error messages
$canContinue = TRUE ; // Clear flag if must abort part way through
2008-08-09 16:49:58 +00:00
2015-10-02 13:40:44 +03:00
if ( is_array ( $id )) // plugin info array
2014-01-20 06:20:58 -08:00
{
$plug = $id ;
2015-10-02 13:40:44 +03:00
$id = ( int ) $plug [ 'plugin_id' ];
2014-01-20 06:20:58 -08:00
}
2015-10-02 13:40:44 +03:00
elseif ( is_numeric ( $id )) // plugin database id
2014-01-20 06:20:58 -08:00
{
$id = ( int ) $id ;
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $id ); // Get plugin info from DB
2014-01-20 06:20:58 -08:00
}
2015-10-02 13:40:44 +03:00
else // Plugin Path.
{
$id = $this -> getId ( $id );
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $id ); // Get plugin info from DB
2015-10-02 13:40:44 +03:00
}
2015-01-27 13:00:33 -08:00
2008-02-02 03:23:47 +00:00
$this -> current_plug = $plug ;
2014-01-20 06:20:58 -08:00
2008-02-02 22:04:18 +00:00
$txt = '' ;
2008-02-01 14:11:27 +00:00
$path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2009-12-09 22:38:18 +00:00
2009-09-23 23:18:18 +00:00
$this -> plugFolder = $plug [ 'plugin_path' ];
2012-12-12 18:46:34 -08:00
2009-09-23 23:18:18 +00:00
$this -> unInstallOpts = $options ;
2009-12-09 22:38:18 +00:00
2008-02-01 14:11:27 +00:00
$addons = explode ( ',' , $plug [ 'plugin_addons' ]);
$sql_list = array ();
2010-06-23 10:21:21 +00:00
foreach ( $addons as $addon )
2008-02-01 14:11:27 +00:00
{
2010-06-23 10:21:21 +00:00
if ( substr ( $addon , - 4 ) == '_sql' )
2008-02-01 14:11:27 +00:00
{
$sql_list [] = $addon . '.php' ;
}
}
2008-01-28 02:49:50 +00:00
2010-06-23 10:21:21 +00:00
if ( ! file_exists ( $path . 'plugin.xml' ) || $function == '' )
2008-01-27 01:34:59 +00:00
{
2008-12-30 09:44:23 +00:00
$error [] = EPL_ADLAN_77 ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Cannot find plugin.xml " ); // Do NOT LAN. Debug Only.
2015-02-01 02:07:56 -08:00
$canContinue = false ;
2008-01-27 01:34:59 +00:00
}
2010-06-23 10:21:21 +00:00
if ( $canContinue && $this -> parse_plugin_xml ( $plug [ 'plugin_path' ]))
2008-01-27 01:34:59 +00:00
{
2008-12-30 09:44:23 +00:00
$plug_vars = $this -> plug_vars ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Vars: " . print_r ( $plug_vars , true ));
2008-01-27 01:34:59 +00:00
}
else
{
2008-12-30 09:44:23 +00:00
$error [] = EPL_ADLAN_76 ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Error in plugin.xml " );
2008-12-30 09:44:23 +00:00
$canContinue = FALSE ;
2008-08-09 16:49:58 +00:00
}
2012-12-08 00:36:34 -08:00
2012-12-23 15:00:15 +00:00
// Load install language file and set lan_global pref.
2016-02-12 19:28:35 -08:00
$this -> XmlLanguageFiles ( $function , varset ( $plug_vars [ 'languageFiles' ]), 'pre' ); // First of all, see if there's a language file specific to install
2009-10-20 03:49:28 +00:00
2008-08-10 11:41:13 +00:00
// Next most important, if installing or upgrading, check that any dependencies are met
2016-06-29 20:48:00 +02:00
if ( $canContinue && ( $function != 'uninstall' ) && isset ( $plug_vars [ 'dependencies' ]))
2008-08-09 16:49:58 +00:00
{
2009-09-23 23:18:18 +00:00
$canContinue = $this -> XmlDependencies ( $plug_vars [ 'dependencies' ]);
2008-08-09 16:49:58 +00:00
}
2015-02-01 02:07:56 -08:00
if ( $canContinue === false )
2008-08-09 16:49:58 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Cannot Continue. Line: " . __LINE__ ); // Do NOT LAN. Debug Only.
2015-02-01 02:07:56 -08:00
return false ;
2008-01-27 01:34:59 +00:00
}
2008-02-01 14:11:27 +00:00
2008-08-09 16:49:58 +00:00
// All the dependencies are OK - can start the install now
2012-12-08 00:36:34 -08:00
2015-02-01 02:07:56 -08:00
// Run custom {plugin}_setup install/upgrade etc. for INSERT, ALTER etc. etc. etc.
$ret = $this -> execute_function ( $plug [ 'plugin_path' ], $function , 'pre' );
if ( ! is_bool ( $ret ))
2009-12-09 22:38:18 +00:00
{
2015-02-01 02:07:56 -08:00
$txt .= $ret ;
2008-08-12 20:26:53 +00:00
}
2015-02-01 02:07:56 -08:00
2012-11-13 21:40:29 +00:00
// Handle tables
2015-04-24 19:03:35 -07:00
$this -> XmlTables ( $function , $plug , $options );
2012-12-08 00:36:34 -08:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'adminLinks' ]))
2009-10-20 03:49:28 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlAdminLinks ( $function , $plug_vars [ 'adminLinks' ]);
2009-10-20 03:49:28 +00:00
}
2009-12-09 22:38:18 +00:00
2016-04-30 12:02:02 -07:00
if ( ! empty ( $plug_vars [ 'siteLinks' ]))
2009-09-23 23:18:18 +00:00
{
2015-02-06 00:14:55 -08:00
$this -> XmlSiteLinks ( $function , $plug_vars );
2009-09-23 23:18:18 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'mainPrefs' ])) //Core pref items <mainPrefs>
2009-09-23 23:18:18 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlPrefs ( 'core' , $function , $plug_vars [ 'mainPrefs' ]);
2009-12-09 22:38:18 +00:00
}
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'pluginPrefs' ])) //Plugin pref items <pluginPrefs>
2009-09-23 23:18:18 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlPrefs ( $plug [ 'plugin_path' ], $function , $plug_vars [ 'pluginPrefs' ]);
2009-09-23 23:18:18 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'userClasses' ]))
2009-09-23 23:18:18 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlUserClasses ( $function , $plug_vars [ 'userClasses' ]);
2009-09-23 23:18:18 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'extendedFields' ]))
2009-09-23 23:18:18 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlExtendedFields ( $function , $plug_vars [ 'extendedFields' ]);
2009-09-23 23:18:18 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'languageFiles' ]))
2009-09-23 23:18:18 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlLanguageFiles ( $function , $plug_vars [ 'languageFiles' ]);
2009-09-23 23:18:18 +00:00
}
2012-07-18 06:34:26 +00:00
if ( varset ( $plug_vars [ 'bbcodes' ]))
{
$this -> XmlBBcodes ( $function , $plug_vars );
}
2012-08-19 02:33:43 +00:00
if ( varset ( $plug_vars [ 'mediaCategories' ]))
{
$this -> XmlMediaCategories ( $function , $plug_vars );
}
2009-12-09 22:38:18 +00:00
2021-01-18 18:10:00 -08:00
$this -> addonMenu ( $this -> plugFolder , $function , $plug_vars [ 'files' ]);
$this -> addonUser ( $this -> plugFolder , $function );
2017-01-26 15:37:42 -08:00
2010-06-23 10:21:21 +00:00
$this -> manage_icons ( $this -> plugFolder , $function );
2009-12-09 22:38:18 +00:00
//FIXME
2009-09-23 23:18:18 +00:00
//If any commentIDs are configured, we need to remove all comments on uninstall
2010-06-23 10:21:21 +00:00
if ( $function == 'uninstall' && isset ( $plug_vars [ 'commentID' ]))
2009-09-23 23:18:18 +00:00
{
$txt .= 'Removing all plugin comments: (' . implode ( ', ' , $plug_vars [ 'commentID' ]) . ')<br />' ;
2018-08-03 16:36:21 -07:00
$commentArray = array ();
2009-09-23 23:18:18 +00:00
$this -> manage_comments ( 'remove' , $commentArray );
}
$this -> manage_search ( $function , $plug_vars [ 'folder' ]);
$this -> manage_notify ( $function , $plug_vars [ 'folder' ]);
$eplug_addons = $this -> getAddons ( $plug [ 'plugin_path' ]);
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
$p_installed = e107 :: getPref ( 'plug_installed' , array ()); // load preference;
2009-09-23 23:18:18 +00:00
2014-05-22 14:54:56 -07:00
if ( $function == 'install' || $function == 'upgrade' || $function == 'refresh' )
2009-12-09 22:38:18 +00:00
{
2013-03-27 19:34:45 -07:00
$sql -> update ( 'plugin' , " plugin_installflag = 1, plugin_addons = ' { $eplug_addons } ', plugin_version = ' { $plug_vars [ '@attributes' ][ 'version' ] } ', plugin_category =' " . $this -> manage_category ( $plug_vars [ 'category' ]) . " ' WHERE plugin_id = " . $id );
2009-09-23 23:18:18 +00:00
$p_installed [ $plug [ 'plugin_path' ]] = $plug_vars [ '@attributes' ][ 'version' ];
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( 'plug_installed' , $p_installed );
2012-01-06 09:49:08 +00:00
//e107::getConfig('core')->save(); - save triggered below
2009-09-23 23:18:18 +00:00
}
2010-06-23 10:21:21 +00:00
if ( $function == 'uninstall' )
2009-09-23 23:18:18 +00:00
{
2013-03-27 19:34:45 -07:00
$sql -> update ( 'plugin' , " plugin_installflag = 0, plugin_addons = ' { $eplug_addons } ', plugin_version = ' { $plug_vars [ '@attributes' ][ 'version' ] } ', plugin_category =' " . $this -> manage_category ( $plug_vars [ 'category' ]) . " ' WHERE plugin_id = " . $id );
2009-09-23 23:18:18 +00:00
unset ( $p_installed [ $plug [ 'plugin_path' ]]);
2013-04-27 02:47:26 -07:00
2010-06-23 10:21:21 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( 'plug_installed' , $p_installed );
2009-12-09 22:38:18 +00:00
2016-10-27 11:13:38 -07:00
$this -> removeCrons ( $plug_vars );
2009-09-23 23:18:18 +00:00
}
2012-01-06 09:49:08 +00:00
2017-01-26 15:37:42 -08:00
2013-04-27 02:47:26 -07:00
2012-01-06 09:49:08 +00:00
$this -> rebuildUrlConfig ();
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
$this -> log ( " Updated 'plug_installed' core pref. " );
2015-04-24 19:03:35 -07:00
e107 :: getConfig ( 'core' ) -> save ( true , false , false );
2018-08-05 15:08:54 -07:00
/*
e107 :: getPlug () -> clearCache () -> buildAddonPrefLists ();
2009-09-23 23:18:18 +00:00
2018-08-05 15:08:54 -07:00
if ( $function === 'install' )
{
e107 :: getPlug () -> setInstalled ( $plug_vars [ 'folder' ], $plug_vars [ '@attributes' ][ 'version' ]);
}
*/
// e107::getPlug()->setInstalled($plug_vars['folder'],$plug_vars['@attributes']['version'])->buildAddonPrefLists();
// e107::getPlug()->clearCache()->setInstalled($plug_vars['folder'],$plug_vars['@attributes']['version'])->buildAddonPrefLists();
2018-08-06 13:07:13 -07:00
$this -> save_addon_prefs ( 'update' ); // to be replaced with buildAddonPrefLists(); once working correctly.
2017-02-07 08:57:18 -08:00
2012-11-13 21:40:29 +00:00
/* if ( $function == 'install' )
2010-06-23 10:21:21 +00:00
{
if ( isset ( $plug_vars [ 'management' ][ 'installDone' ][ 0 ]))
{
$mes -> add ( $plug_vars [ 'management' ][ 'installDone' ][ 0 ], E_MESSAGE_SUCCESS );
}
} */
2022-04-04 18:30:33 -07:00
$xmlInstallStatus = $this -> XmlInstallXml ( $function , $plug_vars [ 'folder' ]);
if ( $xmlInstallStatus )
{
e107 :: getMessage () -> addDebug ( " Default content added to table(s). " );
}
elseif ( $xmlInstallStatus === false )
{
e107 :: getMessage () -> addDebug ( " Failed to add content to table(s). " );
}
2012-11-13 21:40:29 +00:00
// Run custom {plugin}_setup install/upgrade etc. for INSERT, ALTER etc. etc. etc.
// Call any custom post functions defined in <plugin>_setup.php or the deprecated <management> section
2012-12-08 00:36:34 -08:00
if ( ! $this -> execute_function ( $plug [ 'plugin_path' ], $function , 'post' ))
2009-10-20 03:49:28 +00:00
{
2010-06-23 10:21:21 +00:00
if ( $function == 'install' )
2009-10-20 03:49:28 +00:00
{
2016-10-15 20:10:16 +02:00
$text = EPL_ADLAN_238 ;
2009-10-20 03:49:28 +00:00
2010-06-23 10:21:21 +00:00
if ( $this -> plugConfigFile )
2009-10-20 03:49:28 +00:00
{
2013-03-05 15:08:23 -08:00
$text .= " <br /><a class='btn btn-primary' href=' " . $this -> plugConfigFile . " '> " . LAN_CONFIGURE . " </a> " ;
2009-10-20 03:49:28 +00:00
}
2009-12-09 22:38:18 +00:00
2013-02-27 15:18:48 +01:00
$mes -> addSuccess ( $text );
2009-12-09 22:38:18 +00:00
}
}
2018-08-05 15:08:54 -07:00
$event -> trigger ( 'admin_plugin_' . $function , $plug );
2017-02-03 20:18:45 -08:00
2017-01-26 15:37:42 -08:00
return null ;
2009-09-23 23:18:18 +00:00
}
2009-10-20 03:49:28 +00:00
2022-04-04 18:30:33 -07:00
/**
* Check for / xml / install . xml file and import database content only .
* @ param string $function
* @ param string $folder
* @ return bool | null
*/
function XmlInstallXml ( $function , $folder )
{
if ( $function !== 'install' )
{
return null ;
}
$this -> log ( " Running " . __FUNCTION__ );
$path = e_PLUGIN . $folder . '/xml/install.xml' ;
if ( ! file_exists ( $path ))
{
$this -> log ( " No xml/install.xml file found. " );
return null ;
}
$ret = e107 :: getXml () -> e107Import ( $path , 'install' );
if ( ! empty ( $ret [ 'success' ]))
{
return true ;
}
return false ;
}
2015-04-24 19:03:35 -07:00
2022-04-04 10:54:24 -07:00
/**
* @ param $plug_vars
* @ return false
*/
2016-10-27 11:13:38 -07:00
private function removeCrons ( $plug_vars )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __METHOD__ );
2016-10-27 11:13:38 -07:00
if ( ! file_exists ( e_PLUGIN . $plug_vars [ 'folder' ] . " /e_cron.php " ))
{
return false ;
}
if ( e107 :: getDb () -> delete ( 'cron' , 'cron_function LIKE "' . $plug_vars [ 'folder' ] . '::%"' ))
{
2017-01-26 15:37:42 -08:00
$this -> log ( $plug_vars [ 'folder' ] . " crons removed successfully. " ); // no LANs.
2016-10-27 11:13:38 -07:00
e107 :: getMessage () -> addDebug ( $plug_vars [ 'folder' ] . " crons removed successfully. " ); // No LAN necessary
}
return false ;
}
2021-01-18 18:10:00 -08:00
/**
* Manager e_user extended fields
* @ param string $plug
* @ param string $function
* @ param array $opts
* @ return null
*/
private function addonUser ( $plug , $function , $opts = array ())
{
$this -> log ( " Running " . __FUNCTION__ );
$path = e_PLUGIN . $plug . '/e_user.php' ;
if ( ! file_exists ( e_PLUGIN . $plug . '/e_user.php' ))
{
$this -> log ( " No e_user.php addon found. " );
return null ;
}
require_once ( $path );
if ( ! $list = e107 :: callMethod ( $plug . '_user' , 'settings' ))
{
$this -> log ( " Settings method NOT found " );
return null ;
}
$this -> log ( " Settings method found: " . print_r ( $list , true ));
$ue = e107 :: getUserExt ();
foreach ( $list as $field => $attrib )
{
$read = varset ( $attrib [ 'read' ], e_UC_MEMBER );
$write = varset ( $attrib [ 'write' ], e_UC_MEMBER );
$applic = varset ( $attrib [ 'applicable' ], e_UC_MEMBER );
$req = varset ( $attrib [ 'required' ], 0 );
$type = varset ( $attrib [ 'fieldType' ], 'VARCHAR(255)' );
unset ( $attrib [ 'read' ], $attrib [ 'write' ], $attrib [ 'applicable' ], $attrib [ 'required' ], $attrib [ 'fieldType' ]);
$name = $this -> ue_field_name ( $plug , EUF_ADDON , $field );
$insert = array (
'name' => $name ,
'text' => varset ( $attrib [ 'title' ], " None Specified " ),
'type' => EUF_ADDON ,
'parms' => $plug ,
'values' => e107 :: serialize ( $attrib , 'json' ),
'default' => null ,
'parent' => 0 ,
'required' => $req ,
'read' => $read ,
'write' => $write ,
'applicable' => $applic ,
'fieldType' => $type ,
);
switch ( $function )
{
case " install " :
if ( $ue -> user_extended_add ( $insert ))
{
$this -> log ( " User Ext. field added. ( " . $field . " ) " );
e107 :: getMessage () -> addSuccess ( EPL_ADLAN_249 . $name . ' ... ' );
}
else
{
e107 :: getMessage () -> addError ( EPL_ADLAN_249 . $name . ' ... ' );
$this -> log ( " ERROR: User Ext. field couldn't be added. " . print_r ( $insert , true ));
}
break ;
case " uninstall " :
if ( $ue -> user_extended_remove ( $name , $name ))
{
e107 :: getMessage () -> addSuccess ( EPL_ADLAN_250 . $name . ' ... ' );
$this -> log ( " User Ext. field removed. ( " . $field . " ) " );
}
else
{
e107 :: getMessage () -> addError ( EPL_ADLAN_250 . $name . ' ... ' );
$this -> log ( " ERROR: User Ext. field couldn't be removed. ( " . $field . " ) " );
}
break ;
default :
// code to be executed if n is different from all labels;
}
}
}
/**
* Manage xxxxx_menu files .
* @ param string $plug
* @ param string $function
* @ param $files
* @ return false | null
*/
private function addonMenu ( $plug , $function , $files )
2017-01-26 15:37:42 -08:00
{
$this -> log ( " Running " . __FUNCTION__ );
$menuFiles = array ();
2016-10-27 11:13:38 -07:00
2017-01-26 15:37:42 -08:00
foreach ( $files as $file )
{
if ( $file === 'e_menu.php' )
{
continue ;
}
if ( substr ( $file , - 9 ) === '_menu.php' )
{
$menuFiles [] = basename ( $file , '.php' );
}
}
$this -> log ( " Scanning for _menu.php files - " . count ( $menuFiles ) . " found. " ); // Debug info, no LAN
if ( empty ( $menuFiles ))
{
return false ;
}
switch ( $function )
{
case " install " :
case " refresh " :
$this -> log ( " Adding menus to menus table. " ); // NO LANS - debug info!
foreach ( $menuFiles as $menu )
{
if ( ! e107 :: getMenu () -> add ( $plug , $menu ))
{
$this -> log ( " Couldn't add " . $menu . " to menus table. " ); // NO LAN
}
}
break ;
case " uninstall " :
$this -> log ( " Removing menus from menus table. " ); // No Lan
if ( ! e107 :: getMenu () -> remove ( $plug ))
{
$this -> log ( " Couldn't remove menus for plugin: " . $plug ); // NO LAN
}
break ;
}
return null ;
}
2015-04-24 19:03:35 -07:00
/**
* Parse { plugin } _sql . php file and install / upgrade / uninstall tables .
* @ param $function string install | upgrade | uninstall
* @ param $plug - array of plugin data - mostly $plug [ 'plugin_path' ]
* @ param array $options
*/
function XmlTables ( $function , $plug , $options = array ())
2012-11-13 21:40:29 +00:00
{
2020-12-31 08:01:34 -08:00
$txt = '' ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __METHOD__ );
2015-02-01 02:07:56 -08:00
2015-06-30 10:34:38 -07:00
$sqlFile = e_PLUGIN . $plug [ 'plugin_path' ] . '/' . str_replace ( " _menu " , " " , $plug [ 'plugin_path' ]) . " _sql.php " ;
2015-02-01 02:07:56 -08:00
2015-04-24 19:03:35 -07:00
if ( ! file_exists ( $sqlFile )) // No File, so return;
{
2017-01-26 15:37:42 -08:00
$this -> log ( " No SQL File Found at: " . $sqlFile );
2018-08-05 15:08:54 -07:00
return null ;
2015-04-24 19:03:35 -07:00
}
if ( ! is_readable ( $sqlFile )) // File Can't be read.
2015-02-01 02:07:56 -08:00
{
2015-04-24 19:03:35 -07:00
e107 :: getMessage () -> addError ( " Can't read SQL definition: " . $sqlFile );
2017-01-26 15:37:42 -08:00
$this -> log ( " Can't read SQL definition: " . $sqlFile );
2018-08-05 15:08:54 -07:00
return null ;
2015-02-01 02:07:56 -08:00
}
2017-02-07 14:51:33 -08:00
$dbv = e107 :: getSingleton ( 'db_verify' , e_HANDLER . " db_verify_class.php " );
// require_once(e_HANDLER."db_verify_class.php");
// $dbv = new db_verify;
2015-04-24 19:03:35 -07:00
$sql = e107 :: getDb ();
// Add or Remove Table --------------
2015-04-24 20:19:18 -07:00
if ( $function == 'install' || $function == 'uninstall' )
2015-04-24 19:03:35 -07:00
{
$contents = file_get_contents ( $sqlFile );
if ( empty ( $contents ))
{
e107 :: getMessage () -> addError ( " Can't read SQL definition: " . $sqlFile );
2017-01-26 15:37:42 -08:00
$this -> log ( " Can't read SQL definition: " . $sqlFile );
2018-08-05 15:08:54 -07:00
return null ;
2015-04-24 19:03:35 -07:00
}
2017-02-03 13:02:08 -08:00
$tableData = $dbv -> getSqlFileTables ( $contents );
2015-04-24 19:03:35 -07:00
2020-01-17 19:58:58 +01:00
$query = '' ;
2015-04-24 19:03:35 -07:00
foreach ( $tableData [ 'tables' ] as $k => $v )
{
switch ( $function )
{
case " install " :
$query = " CREATE TABLE ` " . MPREFIX . $v . " ` ( \n " ;
$query .= $tableData [ 'data' ][ $k ];
$query .= " \n ) ENGINE= " . vartrue ( $tableData [ 'engine' ][ $k ], " InnoDB " ) . " DEFAULT CHARSET=utf8 " ;
2016-10-15 20:10:16 +02:00
$txt = EPL_ADLAN_239 . " <b> { $v } </b> " ;
2015-04-24 19:03:35 -07:00
$status = $sql -> db_Query ( $query ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
break ;
case " uninstall " :
if ( ! empty ( $options [ 'delete_tables' ]))
{
$query = " DROP TABLE ` " . MPREFIX . $v . " `; " ;
2016-10-15 20:10:16 +02:00
$txt = EPL_ADLAN_240 . " <b> { $v } </b><br /> " ;
2015-04-24 19:03:35 -07:00
$status = $sql -> db_Query_all ( $query ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
}
else
{
$status = E_MESSAGE_SUCCESS ;
$txt = " Table { $v } left in place. " ;
}
break ;
}
e107 :: getMessage () -> add ( $txt , $status );
e107 :: getMessage () -> addDebug ( $query );
}
}
// Upgrade Table --------------
2015-02-01 02:07:56 -08:00
if ( $function == 'upgrade' )
{
$dbv -> errors = array ();
$dbv -> compare ( $plug [ 'plugin_path' ]);
if ( $dbv -> errors ())
{
$dbv -> compileResults ();
$dbv -> runFix ();
}
}
2012-11-13 21:40:29 +00:00
}
2016-06-29 20:48:00 +02:00
/**
* Check if plugin is being used by another plugin before uninstalling it .
*
* @ param array $plugin
* Plugin name .
*
* @ return boolean
* TRUE if plugin is used , otherwise FALSE .
*/
function isUsedByAnotherPlugin ( $plugin )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2016-06-29 20:48:00 +02:00
$db = e107 :: getDb ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$xml = e107 :: getXml ();
$pluginIsUsed = false ;
$enPlugs = array ();
$usedBy = array ();
// Get list of enabled plugins.
$db -> select ( " plugin " , " * " , " plugin_id !='' order by plugin_path ASC " );
while ( $row = $db -> fetch ())
{
if ( $row [ 'plugin_installflag' ] == 1 )
{
$enPlugs [] = $row [ 'plugin_path' ];
}
}
foreach ( $enPlugs as $enPlug )
{
if ( ! file_exists ( e_PLUGIN . $enPlug . '/plugin.xml' ))
{
continue ;
}
$plugInfo = $xml -> loadXMLfile ( e_PLUGIN . $enPlug . '/plugin.xml' , 'advanced' );
if ( $plugInfo === false )
{
continue ;
}
if ( ! isset ( $plugInfo [ 'dependencies' ]))
{
continue ;
}
// FIXME too many nested foreach, need refactoring.
foreach ( $plugInfo [ 'dependencies' ] as $dt => $da )
{
foreach ( $da as $dv )
{
if ( isset ( $dv [ '@attributes' ]) && isset ( $dv [ '@attributes' ][ 'name' ]))
{
switch ( $dt )
{
case 'plugin' :
if ( $dv [ '@attributes' ][ 'name' ] == $plugin )
{
$usedBy [] = $enPlug ;
}
break ;
}
}
}
}
}
if ( count ( $usedBy ))
{
$pluginIsUsed = true ;
$text = '<b>' . LAN_UNINSTALL_FAIL . '</b><br />' ;
$text .= $tp -> lanVars ( LAN_PLUGIN_IS_USED , array ( 'x' => $plugin ), true ) . ' ' ;
$text .= implode ( ', ' , $usedBy );
$mes -> addError ( $text );
}
return $pluginIsUsed ;
}
2009-09-23 23:18:18 +00:00
/**
* Process XML Tag < dependencies > ( deprecated 'depend' which is a brand of adult diapers )
2016-06-29 20:48:00 +02:00
*
* @ param array $tags
* Tags ( in < dependencies > tag ) from XML file .
*
2009-09-23 23:18:18 +00:00
* @ return boolean
*/
2016-06-29 20:48:00 +02:00
function XmlDependencies ( $tags )
2009-09-23 23:18:18 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __METHOD__ );
2016-06-29 20:48:00 +02:00
$db = e107 :: getDb ();
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2016-06-29 20:48:00 +02:00
$canContinue = true ;
$enabledPlugins = array ();
2009-09-23 23:18:18 +00:00
$error = array ();
2009-12-09 22:38:18 +00:00
2016-06-29 20:48:00 +02:00
// Get list of enabled plugins.
$db -> select ( " plugin " , " * " , " plugin_id !='' order by plugin_path ASC " );
while ( $row = $db -> fetch ())
{
if ( $row [ 'plugin_installflag' ] == 1 )
{
$enabledPlugins [ $row [ 'plugin_path' ]] = $row [ 'plugin_version' ];
}
}
// FIXME too many nested foreach, need refactoring.
foreach ( $tags as $dt => $da )
2016-06-29 12:04:14 +02:00
{
2016-06-29 20:48:00 +02:00
foreach ( $da as $dv )
{
if ( isset ( $dv [ '@attributes' ]) && isset ( $dv [ '@attributes' ][ 'name' ]))
{
switch ( $dt )
{
2016-06-29 12:04:14 +02:00
case 'plugin' :
2016-06-29 20:48:00 +02:00
if ( ! isset ( $enabledPlugins [ $dv [ '@attributes' ][ 'name' ]]))
{ // Plugin not installed
$canContinue = false ;
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_70 . $dv [ '@attributes' ][ 'name' ];
}
2016-06-29 20:48:00 +02:00
elseif ( isset ( $dv [ '@attributes' ][ 'min_version' ]) && ( version_compare ( $dv [ '@attributes' ][ 'min_version' ], $enabledPlugins [ $dv [ '@attributes' ][ 'name' ]], '<=' ) === false ))
{
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_71 . $dv [ '@attributes' ][ 'name' ] . EPL_ADLAN_72 . $dv [ '@attributes' ][ 'min_version' ];
2016-06-29 20:48:00 +02:00
$canContinue = false ;
2016-06-29 12:04:14 +02:00
}
break ;
case 'extension' :
2016-06-29 20:48:00 +02:00
if ( ! extension_loaded ( $dv [ '@attributes' ][ 'name' ]))
{
$canContinue = false ;
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_73 . $dv [ '@attributes' ][ 'name' ];
}
2016-06-29 20:48:00 +02:00
elseif ( isset ( $dv [ '@attributes' ][ 'min_version' ]) && ( version_compare ( $dv [ '@attributes' ][ 'min_version' ], phpversion ( $dv [ '@attributes' ][ 'name' ]), '<=' ) === false ))
{
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_71 . $dv [ '@attributes' ][ 'name' ] . EPL_ADLAN_72 . $dv [ '@attributes' ][ 'min_version' ];
2016-06-29 20:48:00 +02:00
$canContinue = false ;
2016-06-29 12:04:14 +02:00
}
break ;
case 'php' : // all should be lowercase
2016-06-29 20:48:00 +02:00
if ( isset ( $dv [ '@attributes' ][ 'min_version' ]) && ( version_compare ( $dv [ '@attributes' ][ 'min_version' ], phpversion (), '<=' ) === false ))
{
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_74 . $dv [ '@attributes' ][ 'min_version' ];
2016-06-29 20:48:00 +02:00
$canContinue = false ;
2016-06-29 12:04:14 +02:00
}
break ;
case 'mysql' : // all should be lowercase
2021-03-10 19:36:45 +00:00
if ( isset ( $dv [ '@attributes' ][ 'min_version' ]) && ( version_compare ( $dv [ '@attributes' ][ 'min_version' ], $db -> getServerInfo (), '<=' ) === false )
2016-06-29 20:48:00 +02:00
)
{
2016-06-29 12:04:14 +02:00
$error [] = EPL_ADLAN_75 . $dv [ '@attributes' ][ 'min_version' ];
2016-06-29 20:48:00 +02:00
$canContinue = false ;
2016-06-29 12:04:14 +02:00
}
break ;
default :
2016-06-29 20:48:00 +02:00
// TODO lan
2016-06-29 12:04:14 +02:00
echo " Unknown dependency: { $dt } <br /> " ;
}
2010-06-23 10:21:21 +00:00
}
2009-09-23 23:18:18 +00:00
}
}
2009-12-09 22:38:18 +00:00
2016-06-29 20:48:00 +02:00
if ( count ( $error ))
2009-09-23 23:18:18 +00:00
{
2016-06-29 20:48:00 +02:00
$text = '<b>' . LAN_INSTALL_FAIL . '</b><br />' . implode ( '<br />' , $error );
2013-02-27 15:18:48 +01:00
$mes -> addError ( $text );
2009-09-23 23:18:18 +00:00
}
2009-12-09 22:38:18 +00:00
2009-09-23 23:18:18 +00:00
return $canContinue ;
}
2009-12-09 22:38:18 +00:00
2012-12-23 15:00:15 +00:00
2009-09-23 23:18:18 +00:00
/**
2012-12-23 15:00:15 +00:00
* Look for a language file in the two acceptable places .
* If found , update the appropriate pref
*
* @ param string $fileEnd - the suffix of the file name ( e . g . '_global' )
* @ param string $prefName - the name of the pref to be updated
* @ param string $when = install | upgrade | refresh | uninstall ( 'update' also supported as alias for 'upgrade' )
* @ param string $isInstalled - flag indicates whether plugin installed
* - if false , any preference is removed .
* - if TRUE , any preference is added
* - so set TRUE to add value to pref regardless
2012-12-28 21:19:22 +00:00
* @ param boolean $justPath
* - if TRUE , plugin name is written to pref , as a generic string which requires a search to locate the file .
* - if FALSE , a precise path within the plugin folder , which includes '--LAN--' strings to substitute for language , is written
* @ param string $plugin - name of plugin folder . If empty string , $this -> plugFolder is used ( may not always exist ) .
2012-12-23 15:00:15 +00:00
*
* @ return boolean TRUE if pref changed
*/
2012-12-28 21:19:22 +00:00
public function XmlLanguageFileCheck ( $fileEnd , $prefName , $when , $isInstalled , $justPath = FALSE , $plugin = '' )
2012-12-23 15:00:15 +00:00
{
$core = e107 :: getConfig ( 'core' );
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2012-12-23 15:00:15 +00:00
if ( trim ( $plugin ) == '' ) $plugin = $this -> plugFolder ;
2012-12-28 21:19:22 +00:00
if ( ! $plugin ) return FALSE ; // No plugin name - error
2012-12-23 15:00:15 +00:00
if ( ! $isInstalled ) $when = 'uninstall' ;
$updated = false ;
$path_a = e_PLUGIN . $plugin . '/languages/English' . $fileEnd . '.php' ; // always check for English so we have a fall-back
$path_b = e_PLUGIN . $plugin . '/languages/English/English' . $fileEnd . '.php' ;
$pathEntry = '' ;
if ( file_exists ( $path_a ))
{
2012-12-28 21:19:22 +00:00
$pathEntry = $justPath ? $plugin : '--LAN--' . $fileEnd . '.php' ;
2012-12-23 15:00:15 +00:00
}
elseif ( file_exists ( $path_b ))
{
2012-12-28 21:19:22 +00:00
$pathEntry = $justPath ? $plugin : '--LAN--/--LAN--' . $fileEnd . '.php' ;
2012-12-23 15:00:15 +00:00
}
$currentPref = $core -> getPref ( $prefName . '/' . $plugin );
2013-02-11 14:25:59 +02:00
//echo 'Path: '.$plugin.' Pref: '.$prefName.' Current: '.$currentPref.' New: '.$pathEntry.'<br />';
2012-12-23 15:00:15 +00:00
switch ( $when )
{
case 'install' :
case 'upgrade' :
case 'update' :
case 'refresh' :
if ( $currentPref != $pathEntry )
{
2016-11-26 08:19:36 +01:00
$mes -> addDebug ( 'Adding ' . $plugin . ' to ' . $prefName );
2012-12-23 15:00:15 +00:00
$core -> setPref ( $prefName . '/' . $plugin , $pathEntry );
$updated = true ;
}
break ;
case 'uninstall' :
if ( $currentPref )
{
2016-11-26 08:19:36 +01:00
$mes -> addDebug ( 'Removing ' . $plugin . ' from ' . $prefName );
2012-12-23 15:00:15 +00:00
$core -> removePref ( $prefName . '/' . $plugin );
$updated = true ;
}
break ;
}
return $updated ;
}
/**
* Process XML Tag < LanguageFiles > // Tag is DEPRECATED - using _install _log and _global
2018-08-05 15:08:54 -07:00
* @ param string $function install | uninstall | upgrade | refresh - should $when have been used ?
2012-12-23 15:00:15 +00:00
* @ param object $tag ( not used ? )
2018-08-05 15:08:54 -07:00
* @ param string $when = install | upgrade | refresh | uninstall
* @ return null
2009-09-23 23:18:18 +00:00
*/
2012-12-12 18:46:34 -08:00
function XmlLanguageFiles ( $function , $tag = '' , $when = '' )
2009-09-23 23:18:18 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-09-23 23:18:18 +00:00
$core = e107 :: getConfig ( 'core' );
2012-12-12 18:46:34 -08:00
$updated = false ;
2012-12-19 11:37:45 +01:00
$path_a = e_PLUGIN . $this -> plugFolder . " /languages/English_install.php " ; // always check for English so we have a fall-back
2012-12-12 18:46:34 -08:00
$path_b = e_PLUGIN . $this -> plugFolder . " /languages/English/English_install.php " ;
if ( file_exists ( $path_a ) || file_exists ( $path_b ))
2009-12-09 22:38:18 +00:00
{
2012-12-12 18:46:34 -08:00
e107 :: lan ( $this -> plugFolder , 'install' , true );
}
2012-12-19 11:37:45 +01:00
$path_a = e_PLUGIN . $this -> plugFolder . " /languages/English_global.php " ; // always check for English so we have a fall-back
2012-12-12 18:46:34 -08:00
$path_b = e_PLUGIN . $this -> plugFolder . " /languages/English/English_global.php " ;
if ( file_exists ( $path_a ) || file_exists ( $path_b ))
{
switch ( $function )
2009-10-20 03:49:28 +00:00
{
2012-12-12 18:46:34 -08:00
case 'install' :
case 'upgrade' :
case 'refresh' :
e107 :: getMessage () -> addDebug ( " Adding " . $this -> plugFolder . " to lan_global_list " );
e107 :: lan ( $this -> plugFolder , 'global' , true );
$core -> setPref ( 'lan_global_list/' . $this -> plugFolder , $this -> plugFolder );
$updated = true ;
break ;
case 'uninstall' :
$core -> removePref ( 'lan_global_list/' . $this -> plugFolder );
$update = true ;
break ;
}
}
2012-12-19 11:37:45 +01:00
$path_a = e_PLUGIN . $this -> plugFolder . " /languages/English_log.php " ; // always check for English so we have a fall-back
2012-12-12 18:46:34 -08:00
$path_b = e_PLUGIN . $this -> plugFolder . " /languages/English/English_log.php " ;
if ( file_exists ( $path_a ) || file_exists ( $path_b ))
{
switch ( $function )
2009-10-20 03:49:28 +00:00
{
2012-12-12 18:46:34 -08:00
case 'install' :
case 'upgrade' :
case 'refresh' :
$core -> setPref ( 'lan_log_list/' . $this -> plugFolder , $this -> plugFolder );
$updated = true ;
break ;
case 'uninstall' :
$core -> removePref ( 'lan_log_list/' . $this -> plugFolder );
$updated = true ;
break ;
}
2009-10-20 03:49:28 +00:00
}
2012-12-12 18:46:34 -08:00
if ( $updated === true )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Prefs saved " );
2016-11-01 12:12:00 -07:00
$core -> save ( true , false , false ); //FIXME do this quietly without an s-message
2012-12-12 18:46:34 -08:00
}
2018-08-05 15:08:54 -07:00
return null ;
2009-09-23 23:18:18 +00:00
}
2009-10-20 03:49:28 +00:00
2009-09-23 23:18:18 +00:00
/**
* Process XML Tag < siteLinks >
* @ param string $function install | upgrade | refresh | uninstall
2022-04-04 10:54:24 -07:00
* @ param array $plug_vars
2018-08-05 15:08:54 -07:00
* @ return null
2009-09-23 23:18:18 +00:00
*/
2015-02-06 00:14:55 -08:00
function XmlSiteLinks ( $function , $plug_vars )
2009-09-23 23:18:18 +00:00
{
2021-01-17 20:31:25 -08:00
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2020-12-31 08:01:34 -08:00
$status = false ;
2009-10-23 09:08:15 +00:00
$mes = e107 :: getMessage ();
2014-01-20 06:20:58 -08:00
2020-12-20 11:50:10 -08:00
if ( ! empty ( $this -> options [ 'nolinks' ]))
2014-01-20 06:20:58 -08:00
{
2018-08-05 15:08:54 -07:00
return null ;
2014-01-20 06:20:58 -08:00
}
2016-04-30 12:02:02 -07:00
2021-01-17 20:31:25 -08:00
2016-04-30 12:02:02 -07:00
if ( $function == 'refresh' )
{
$mes -> addDebug ( " Checking Plugin Site-links " );
$mes -> addDebug ( print_a ( $plug_vars [ 'siteLinks' ], true ));
}
2015-02-06 00:14:55 -08:00
2021-01-17 20:31:25 -08:00
$array = $plug_vars [ 'siteLinks' ];
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
foreach ( $array [ 'link' ] as $link )
2009-09-23 23:18:18 +00:00
{
2012-12-12 21:30:43 -08:00
$attrib = $link [ '@attributes' ];
2015-06-10 14:22:59 -07:00
$linkName = ( defset ( $link [ '@value' ])) ? constant ( $link [ '@value' ]) : vartrue ( $link [ '@value' ], '' );
2021-01-24 17:00:02 -08:00
$remove = varset ( $attrib [ 'deprecate' ]) == 'true' ;
2012-12-12 21:30:43 -08:00
$url = vartrue ( $attrib [ 'url' ]);
$perm = vartrue ( $attrib [ 'perm' ], 'everyone' );
2015-02-06 00:14:55 -08:00
$sef = vartrue ( $attrib [ 'sef' ]);
2012-12-12 21:30:43 -08:00
$options = array (
2018-09-18 09:38:34 -07:00
'link_function' => ! empty ( $attrib [ 'function' ]) ? $plug_vars [ 'folder' ] . '::' . $attrib [ 'function' ] : null ,
2015-02-06 00:14:55 -08:00
'link_owner' => vartrue ( $plug_vars [ 'folder' ]),
2015-06-10 14:22:59 -07:00
'link_sef' => $sef ,
'link_icon' => vartrue ( $attrib [ 'icon' ]),
'link_description' => vartrue ( $attrib [ 'description' ])
2012-12-12 21:30:43 -08:00
);
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
switch ( $function )
{
case 'upgrade' :
case 'install' :
2016-04-30 12:02:02 -07:00
case 'refresh' :
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( ! $remove ) // Add any non-deprecated link
{
2016-04-30 12:02:02 -07:00
if ( $function == 'refresh' )
{
$perm = 'nobody' ;
}
2012-12-12 21:30:43 -08:00
$result = $this -> manage_link ( 'add' , $url , $linkName , $perm , $options );
2012-11-07 20:27:41 +00:00
if ( $result !== NULL )
{
$status = ( $result ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_233 . " { $linkName } URL: [ { $url } ] " . EPL_ADLAN_252 . " { $perm } " , $status );
2012-11-07 20:27:41 +00:00
}
2010-06-23 10:21:21 +00:00
}
2008-12-10 22:39:43 +00:00
2010-06-23 10:21:21 +00:00
if ( $function == 'upgrade' && $remove ) //remove inactive links on upgrade
{
2012-12-12 21:30:43 -08:00
$status = ( $this -> manage_link ( 'remove' , $url , $linkName , false , $options )) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_234 . " { $linkName } URL: [ { $url } ] " , $status );
2010-06-23 10:21:21 +00:00
}
break ;
case 'uninstall' : //remove all links
2015-02-06 00:14:55 -08:00
$status = ( $this -> manage_link ( 'remove' , $url , $linkName , $perm , $options )) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_234 . " { $linkName } URL: [ { $url } ] " , $status );
2010-06-23 10:21:21 +00:00
break ;
2009-12-09 22:38:18 +00:00
}
2010-06-23 10:21:21 +00:00
}
2018-08-05 15:08:54 -07:00
2021-01-24 17:00:02 -08:00
return $status === E_MESSAGE_SUCCESS ;
2009-09-23 23:18:18 +00:00
}
2009-09-21 21:53:38 +00:00
2009-09-23 23:18:18 +00:00
/**
2009-12-09 22:38:18 +00:00
* Process XML Tag < adminLinks >
2018-08-05 15:08:54 -07:00
* @ return null
2009-09-23 23:18:18 +00:00
*/
2010-06-23 10:21:21 +00:00
function XmlAdminLinks ( $function , $tag )
2009-09-23 23:18:18 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2010-06-23 10:21:21 +00:00
foreach ( $tag [ 'link' ] as $link )
2009-10-20 03:49:28 +00:00
{
$attrib = $link [ '@attributes' ];
$url = e_PLUGIN_ABS . $this -> plugFolder . " / " . $attrib [ 'url' ];
2012-01-11 14:54:47 +00:00
if ( isset ( $attrib [ 'primary' ]) && $attrib [ 'primary' ] == 'true' )
2009-10-20 03:49:28 +00:00
{
2009-12-09 22:38:18 +00:00
$this -> plugConfigFile = $url ;
2009-10-20 03:49:28 +00:00
}
}
2018-08-05 15:08:54 -07:00
return null ;
2009-09-23 23:18:18 +00:00
}
2012-08-19 02:33:43 +00:00
2015-02-04 14:37:34 -08:00
2022-04-04 10:54:24 -07:00
/**
* @ param $type
* @ param $default
* @ return int | mixed
*/
2015-02-04 14:37:34 -08:00
function getPerm ( $type , $default = 'member' )
{
if ( empty ( $type ))
{
$type = $default ;
}
$plug_perm = array ();
$plug_perm [ 'everyone' ] = e_UC_PUBLIC ;
$plug_perm [ 'guest' ] = e_UC_GUEST ;
$plug_perm [ 'member' ] = e_UC_MEMBER ;
$plug_perm [ 'mainadmin' ] = e_UC_MAINADMIN ;
$plug_perm [ 'admin' ] = e_UC_ADMIN ;
$plug_perm [ 'nobody' ] = e_UC_NOBODY ;
if ( isset ( $plug_perm [ $type ]))
{
return $plug_perm [ $type ];
}
return $plug_perm [ $default ];
}
2012-08-19 02:33:43 +00:00
// Only 1 category per file-type allowed. ie. 1 for images, 1 for files.
2022-04-04 10:54:24 -07:00
/**
* @ param $function
* @ param $tag
* @ return null
*/
2012-08-19 02:33:43 +00:00
function XmlMediaCategories ( $function , $tag )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2012-08-19 02:33:43 +00:00
$mes = e107 :: getMessage ();
// print_a($tag);
$folder = $tag [ 'folder' ];
$prevType = " " ;
//print_a($tag);
switch ( $function )
{
2016-07-07 14:28:12 -07:00
case 'install' :
case 'refresh' :
2012-08-19 02:33:43 +00:00
$c = 1 ;
2016-10-31 20:34:59 -07:00
$i = array ( 'file' => 1 , 'image' => 1 , 'video' => 1 );
2012-08-19 02:33:43 +00:00
foreach ( $tag [ 'mediaCategories' ][ 'category' ] as $v )
{
$type = $v [ '@attributes' ][ 'type' ];
2012-10-31 21:28:20 +00:00
if ( strpos ( $type , 'image' ) !== 0 && strpos ( $type , 'file' ) !== 0 && strpos ( $type , 'video' ) !== 0 )
2012-08-19 02:33:43 +00:00
{
continue ;
}
2016-10-31 20:34:59 -07:00
if ( $c == 4 )
2012-08-19 02:33:43 +00:00
{
2016-10-15 20:10:16 +02:00
$mes -> addDebug ( EPL_ADLAN_244 );
2012-08-19 02:33:43 +00:00
break ;
}
2016-10-31 20:34:59 -07:00
// $prevType = $type;
2012-08-19 02:33:43 +00:00
2013-04-30 16:16:37 -07:00
$data [ 'owner' ] = $folder ;
$data [ 'image' ] = vartrue ( $v [ '@attributes' ][ 'image' ]);
2016-10-31 20:34:59 -07:00
$data [ 'category' ] = $folder . " _ " . $type ;
if ( $i [ $type ] > 1 )
{
$data [ 'category' ] .= " _ " . $i [ $type ];
}
2013-04-30 16:16:37 -07:00
$data [ 'title' ] = $v [ '@value' ];
$data [ 'sef' ] = vartrue ( $v [ '@attributes' ][ 'sef' ]);
2012-08-19 02:33:43 +00:00
// $data['type'] = $v['@attributes']['type']; //TODO
2016-02-12 19:28:35 -08:00
$data [ 'class' ] = $this -> getPerm ( varset ( $v [ '@attributes' ][ 'perm' ]), 'member' );
2013-04-30 16:16:37 -07:00
2012-08-19 02:33:43 +00:00
$status = e107 :: getMedia () -> createCategory ( $data ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2018-08-18 11:48:10 -07:00
$message = e107 :: getParser () -> lanVars ( EPL_ADLAN_245 , $data [ 'category' ], true );
// $message = str_replace('[x]', $data['category'], EPL_ADLAN_245);
2016-11-25 12:25:15 +01:00
$mes -> add ( $message , $status );
2013-03-09 19:22:30 -08:00
e107 :: getMedia () -> import ( $data [ 'category' ], e_PLUGIN . $folder , false , 'min-size=20000' );
2016-10-31 20:34:59 -07:00
$c ++ ;
$i [ $type ] ++ ;
2012-08-19 02:33:43 +00:00
}
break ;
case 'uninstall' : // Probably best to leave well alone
$status = e107 :: getMedia () -> deleteAllCategories ( $folder ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2018-08-18 11:48:10 -07:00
// $message = str_replace('[x]', $folder, EPL_ADLAN_246);
$message = e107 :: getParser () -> lanVars ( EPL_ADLAN_246 , $folder , true );
2016-11-25 12:25:15 +01:00
$mes -> add ( $message , $status );
2012-08-19 02:33:43 +00:00
break ;
}
2018-08-05 15:08:54 -07:00
return null ;
2012-08-19 02:33:43 +00:00
}
2012-07-18 06:34:26 +00:00
/**
* Process XML Tag < bbcodes >
2018-08-05 15:08:54 -07:00
* @ return null
2012-07-18 06:34:26 +00:00
*/
function XmlBBcodes ( $function , $tag )
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2012-07-18 06:34:26 +00:00
switch ( $function )
{
case 'install' : // Probably best to leave well alone
2020-12-20 11:50:10 -08:00
if ( ! empty ( $tag [ 'bbcodes' ][ '@attributes' ][ 'imgResize' ]))
2012-07-18 06:34:26 +00:00
{
2012-12-12 19:28:39 -08:00
e107 :: getConfig ( 'core' ) -> setPref ( 'resize_dimensions/' . $this -> plugFolder . " -bbcode " , array ( 'w' => 300 , 'h' => 300 ));
2017-01-26 15:37:42 -08:00
$this -> log ( 'Adding imageResize for: ' . $this -> plugFolder );
2012-12-12 19:28:39 -08:00
}
2012-07-18 06:34:26 +00:00
break ;
case 'uninstall' : // Probably best to leave well alone
2020-12-20 11:50:10 -08:00
if ( ! empty ( $tag [ 'bbcodes' ][ '@attributes' ][ 'imgResize' ]))
2012-07-18 06:34:26 +00:00
{
2012-12-12 19:28:39 -08:00
//e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder);
//e107::getConfig('core')->removePref('e_imageresize/'.$this->plugFolder);
e107 :: getConfig ( 'core' ) -> removePref ( 'resize_dimensions/' . $this -> plugFolder . " -bbcode " );
2017-01-26 15:37:42 -08:00
$this -> log ( 'Removing imageResize for: ' . $this -> plugFolder . " -bbcode " );
2012-07-18 06:34:26 +00:00
}
2012-12-12 19:28:39 -08:00
break ;
2012-07-18 06:34:26 +00:00
}
2018-08-05 15:08:54 -07:00
return null ;
2012-07-18 06:34:26 +00:00
}
2008-02-01 14:11:27 +00:00
2009-09-23 23:18:18 +00:00
/**
2009-12-09 22:38:18 +00:00
* Process XML Tag < userClasses >
2009-09-23 23:18:18 +00:00
* @ param string $function install | upgrade | refresh | uninstall
* @ param array $array
2018-08-05 15:08:54 -07:00
* @ return null
2009-09-23 23:18:18 +00:00
*/
2010-06-23 10:21:21 +00:00
function XmlUserClasses ( $function , $array )
2009-09-23 23:18:18 +00:00
{
2009-10-23 09:08:15 +00:00
$mes = e107 :: getMessage ();
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
foreach ( $array [ 'class' ] as $uclass )
2008-01-27 05:16:03 +00:00
{
2010-06-23 10:21:21 +00:00
$attrib = $uclass [ '@attributes' ];
$name = $attrib [ 'name' ];
$description = $attrib [ 'description' ];
2021-01-24 17:00:02 -08:00
$remove = varset ( $attrib [ 'deprecate' ]) == 'true' ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
switch ( $function )
{
case 'install' :
case 'upgrade' :
case 'refresh' :
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( ! $remove ) // Add all active userclasses (code checks for already installed)
{
2012-11-07 20:27:41 +00:00
$result = $this -> manage_userclass ( 'add' , $name , $description );
if ( $result !== NULL )
{
$status = ( $result ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
$mes -> add ( 'Adding Userclass: ' . $name , $status );
}
2010-06-23 10:21:21 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( $function == 'upgrade' && $remove ) //If upgrading, removing any inactive userclass
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
{
$status = $this -> manage_userclass ( 'remove' , $name , $description ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
$mes -> add ( 'Removing Userclass: ' . $name , $status );
}
2008-02-02 22:04:18 +00:00
2010-06-23 10:21:21 +00:00
break ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
case 'uninstall' : //If uninstalling, remove all userclasses (active or inactive)
2009-12-09 22:38:18 +00:00
2015-02-14 23:34:15 -08:00
if ( vartrue ( $this -> unInstallOpts [ 'delete_userclasses' ], FALSE ))
2010-06-23 10:21:21 +00:00
{
$status = $this -> manage_userclass ( 'remove' , $name , $description ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
$mes -> add ( 'Removing Userclass: ' . $name , $status );
}
else
{
2018-07-24 12:03:26 -07:00
$mes -> add ( 'Userclass: ' . $name . ' left in place' , E_MESSAGE_DEBUG );
2010-06-23 10:21:21 +00:00
}
2009-12-09 22:38:18 +00:00
2008-02-02 22:04:18 +00:00
break ;
2010-06-23 10:21:21 +00:00
}
2008-01-27 05:16:03 +00:00
}
2018-08-05 15:08:54 -07:00
return null ;
2009-09-23 23:18:18 +00:00
}
2013-02-27 15:18:48 +01:00
2009-09-23 23:18:18 +00:00
/**
2009-12-09 22:38:18 +00:00
* Process XML Tag < extendedFields >
2009-09-23 23:18:18 +00:00
* @ param string $function install | upgrade | refresh | uninstall
* @ param array $array
2018-08-05 15:08:54 -07:00
* @ return null
2009-09-23 23:18:18 +00:00
*/
2010-06-23 10:21:21 +00:00
function XmlExtendedFields ( $function , $array )
2009-09-23 23:18:18 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-10-23 09:08:15 +00:00
$mes = e107 :: getMessage ();
2011-11-25 17:35:12 +00:00
$this -> setUe ();
2009-12-09 22:38:18 +00:00
2019-05-04 13:32:38 -07:00
$ret = array ();
2010-06-23 10:21:21 +00:00
foreach ( $array [ 'field' ] as $efield )
2008-11-24 00:36:50 +00:00
{
2010-06-23 10:21:21 +00:00
$attrib = $efield [ '@attributes' ];
$attrib [ 'default' ] = varset ( $attrib [ 'default' ]);
2011-11-25 17:35:12 +00:00
$type = $this -> ue_field_type ( $attrib );
$name = $this -> ue_field_name ( $this -> plugFolder , $type , $attrib [ 'name' ]);
//$name = 'plugin_'.$this->plugFolder.'_'.$attrib['name'];
2010-06-23 10:21:21 +00:00
$source = 'plugin_' . $this -> plugFolder ;
2021-01-24 17:00:02 -08:00
$remove = varset ( $attrib [ 'deprecate' ]) == 'true' ;
2011-11-25 17:35:12 +00:00
2019-05-04 13:32:38 -07:00
if ( ! isset ( $attrib [ 'system' ]))
{
$attrib [ 'system' ] = true ; // default true
}
else
{
2021-01-24 17:00:02 -08:00
$attrib [ 'system' ] = $attrib [ 'system' ] === 'true' ;
2019-05-04 13:32:38 -07:00
}
2008-12-05 14:18:51 +00:00
2010-06-23 10:21:21 +00:00
switch ( $function )
{
case 'install' : // Add all active extended fields
2016-04-02 12:47:27 -07:00
case 'upgrade' :
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( ! $remove )
{
2011-11-25 17:35:12 +00:00
//$status = $this->manage_extended_field('add', $name, $type, $attrib['default'], $source) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$status = $this -> manage_extended_field ( 'add' , $name , $attrib , $source ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_249 . $name . ' ... ' , $status );
2010-06-23 10:21:21 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( $function == 'upgrade' && $remove ) //If upgrading, removing any inactive extended fields
2008-11-24 00:36:50 +00:00
2010-06-23 10:21:21 +00:00
{
2011-11-25 17:35:12 +00:00
$status = $this -> manage_extended_field ( 'remove' , $name , $attrib , $source ) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_250 . $name . ' ... ' , $status );
2010-06-23 10:21:21 +00:00
}
break ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
case 'uninstall' : //If uninstalling, remove all extended fields (active or inactive)
2009-12-09 22:38:18 +00:00
2015-02-14 23:34:15 -08:00
if ( vartrue ( $this -> unInstallOpts [ 'delete_xfields' ], FALSE ))
2010-06-23 10:21:21 +00:00
{
2011-11-25 17:35:12 +00:00
$status = ( $this -> manage_extended_field ( 'remove' , $name , $attrib , $source )) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR ;
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_250 . $name . ' ... ' , $status );
2010-06-23 10:21:21 +00:00
}
else
{
2016-11-25 12:25:15 +01:00
$mes -> add ( EPL_ADLAN_251 . $name , E_MESSAGE_SUCCESS );
2010-06-23 10:21:21 +00:00
}
break ;
2019-05-04 13:32:38 -07:00
case 'test' : // phpunit
$ret [] = array ( 'name' => $name , 'attrib' => $attrib , 'source' => $source );
break ;
2008-11-24 00:36:50 +00:00
}
2010-06-23 10:21:21 +00:00
}
2018-08-05 15:08:54 -07:00
2019-05-04 13:32:38 -07:00
if ( ! empty ( $ret ))
{
return $ret ;
}
2018-08-05 15:08:54 -07:00
return null ;
2008-02-02 00:48:58 +00:00
}
2006-12-02 04:36:16 +00:00
2015-02-01 02:07:56 -08:00
2009-09-21 21:53:38 +00:00
/**
2009-09-23 23:18:18 +00:00
* Process XML tags < mainPrefs > and < pluginPrefs >
2018-08-05 15:08:54 -07:00
* @ param string $mode 'core' or the folder name of the plugin .
* @ param string $function install | uninstall | upgrade | refresh
* @ param array $prefArray XML array of prefs . eg . mainPref () or pluginPref ();
* @ return null
2009-09-21 21:53:38 +00:00
*/
2018-08-05 15:08:54 -07:00
function XmlPrefs ( $mode = 'core' , $function = '' , $prefArray = array ())
2009-09-21 21:53:38 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __FUNCTION__ );
2009-12-09 22:38:18 +00:00
2009-10-23 09:08:15 +00:00
$mes = e107 :: getMessage ();
2009-12-09 22:38:18 +00:00
2018-08-05 15:08:54 -07:00
if ( empty ( $prefArray ))
2009-09-21 21:53:38 +00:00
{
2018-08-05 15:08:54 -07:00
return null ;
2009-09-21 21:53:38 +00:00
}
2009-12-09 22:38:18 +00:00
2018-08-05 15:08:54 -07:00
$config = ( $mode === 'core' ) ? e107 :: getConfig ( 'core' ) : e107 :: getPlugConfig ( $mode );
2017-10-03 14:29:28 -07:00
2010-06-23 10:21:21 +00:00
foreach ( $prefArray [ 'pref' ] as $tag )
2009-09-21 21:53:38 +00:00
{
$key = varset ( $tag [ '@attributes' ][ 'name' ]);
2017-10-03 14:29:28 -07:00
$value = varset ( $tag [ '@value' ]);
// $this->log(" Pref: ".$key." => ".$value);
2013-01-31 14:31:03 -08:00
2020-12-20 11:50:10 -08:00
if ( strpos ( $value , " e_UC_ " ) === 0 ) // Convert Userclass constants.
2013-01-31 14:31:03 -08:00
{
$value = constant ( $value );
}
2018-07-23 14:01:08 -07:00
elseif ( $tmp = e107 :: unserialize ( $value )) // check for array data and convert when required. .
{
$value = $tmp ;
}
2013-01-31 14:31:03 -08:00
2021-01-24 17:00:02 -08:00
$remove = varset ( $tag [ '@attributes' ][ 'deprecate' ]) == 'true' ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $tag [ '@attributes' ][ 'value' ]))
2009-09-21 21:53:38 +00:00
{
2013-02-27 15:18:48 +01:00
$mes -> addError ( " Deprecated plugin.xml spec. found. Use the following format: " . htmlentities ( " <pref name='name'>value</pref> " ));
2009-09-21 21:53:38 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
switch ( $function )
2009-09-21 21:53:38 +00:00
{
case 'install' :
2012-11-07 20:27:41 +00:00
case 'upgrade' :
$ret = $config -> add ( $key , $value );
2020-12-08 12:21:12 -08:00
if ( $ret -> isModified ())
2012-11-07 20:27:41 +00:00
{
2016-10-15 20:41:39 +02:00
$mes -> addSuccess ( EPL_ADLAN_241 , $key );
2012-11-07 20:27:41 +00:00
}
2010-06-23 10:21:21 +00:00
break ;
2012-11-07 20:27:41 +00:00
2010-06-23 10:21:21 +00:00
case 'refresh' :
if ( $remove ) // remove active='false' prefs.
2009-12-09 22:38:18 +00:00
2009-09-22 21:12:12 +00:00
{
2018-08-05 15:08:54 -07:00
$config -> remove ( $key );
2016-10-15 20:41:39 +02:00
$mes -> addSuccess ( EPL_ADLAN_242 , $key );
2009-09-22 21:12:12 +00:00
}
else
{
2010-06-23 10:21:21 +00:00
$config -> update ( $key , $value );
2016-10-15 20:41:39 +02:00
$mes -> addSuccess ( EPL_ADLAN_243 , $key );
2009-09-22 21:12:12 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
break ;
2009-12-09 22:38:18 +00:00
2009-09-21 21:53:38 +00:00
case 'uninstall' :
2018-08-05 15:08:54 -07:00
$config -> remove ( $key );
2016-10-15 20:41:39 +02:00
$mes -> addSuccess ( EPL_ADLAN_242 , $key );
2017-01-26 15:37:42 -08:00
$this -> log ( " Removing Pref: " . $key );
2010-06-23 10:21:21 +00:00
break ;
2009-12-09 22:38:18 +00:00
}
2009-09-21 21:53:38 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( $mode != " core " ) // Do only one core pref save during install/uninstall etc.
2009-09-21 21:53:38 +00:00
{
2015-08-24 17:39:28 -07:00
$config -> save ( true , false , false );
2009-12-09 22:38:18 +00:00
}
2018-08-05 15:08:54 -07:00
return null ;
2009-09-21 21:53:38 +00:00
}
2009-10-21 12:53:00 +00:00
/**
2009-12-09 22:38:18 +00:00
*
2009-10-21 12:53:00 +00:00
* @ param object $path [ unused ]
* @ param object $what install | uninstall | upgrade
* @ param object $when pre | post
2013-02-08 09:15:57 +02:00
* @ param array $callbackData callback method arguments
2009-12-13 21:52:32 +00:00
* @ return boolean FALSE
2009-10-21 12:53:00 +00:00
*/
2013-02-08 09:15:57 +02:00
function execute_function ( $path = null , $what = '' , $when = '' , $callbackData = null )
2009-12-09 22:38:18 +00:00
{
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2012-12-08 00:36:34 -08:00
if ( $path == null )
2009-10-20 03:49:28 +00:00
{
2012-12-08 00:36:34 -08:00
$path = $this -> plugFolder ;
2009-12-09 22:38:18 +00:00
}
2012-12-08 00:36:34 -08:00
$class_name = $path . " _setup " ; // was using $this->pluginFolder;
$method_name = $what . " _ " . $when ;
2012-12-08 01:31:00 -08:00
// {PLUGIN}_setup.php should ALWAYS be the name of the file..
2012-12-08 00:36:34 -08:00
// if (varset($this->plug_vars['@attributes']['setupFile']))
// {
// $setup_file = e_PLUGIN.$this->plugFolder.'/'.$this->plug_vars['@attributes']['setupFile'];
// }
// else
// {
$setup_file = e_PLUGIN . $path . '/' . $path . '_setup.php' ;
// }
2009-12-09 22:38:18 +00:00
2016-02-25 18:43:49 -08:00
if ( ! is_readable ( $setup_file ) && substr ( $path , - 5 ) == " _menu " )
{
$setup_file = e_PLUGIN . $path . '/' . str_replace ( " _menu " , " " , $path ) . '_setup.php' ;
}
2016-02-26 12:50:48 -08:00
if ( deftrue ( 'E107_DBG_INCLUDES' ))
{
e107 :: getMessage () -> addDebug ( " Checking for SetUp File: " . $setup_file );
}
2016-02-25 18:43:49 -08:00
2010-06-23 10:21:21 +00:00
if ( is_readable ( $setup_file ))
2009-10-20 03:49:28 +00:00
{
2013-03-31 00:06:21 -07:00
if ( e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES )
2012-12-08 12:50:55 -08:00
{
2013-02-27 15:18:48 +01:00
$mes -> addDebug ( " Found setup file <b> " . $path . " _setup.php</b> " );
2012-12-08 12:50:55 -08:00
}
2009-10-20 03:49:28 +00:00
include_once ( $setup_file );
2012-12-08 00:36:34 -08:00
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( class_exists ( $class_name ))
2009-10-20 03:49:28 +00:00
{
$obj = new $class_name ;
2012-11-07 03:40:07 +00:00
$obj -> version_from = $this ;
2012-12-08 00:36:34 -08:00
2010-06-23 10:21:21 +00:00
if ( method_exists ( $obj , $method_name ))
2009-10-20 03:49:28 +00:00
{
2013-03-31 00:06:21 -07:00
if ( e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES )
2012-12-08 12:50:55 -08:00
{
2013-02-27 15:18:48 +01:00
$mes -> addDebug ( " Executing setup function <b> " . $class_name . " :: " . $method_name . " ()</b> " );
2012-12-08 12:50:55 -08:00
}
2013-02-08 09:15:57 +02:00
if ( null !== $callbackData ) return call_user_func_array ( array ( $obj , $method_name ), $callbackData );
2010-06-23 10:21:21 +00:00
return call_user_func ( array ( $obj , $method_name ), $this );
2009-10-20 03:49:28 +00:00
}
else
{
2013-03-31 00:06:21 -07:00
if ( e_PAGE == 'e107_update.php' && E107_DBG_INCLUDES )
2012-12-08 12:50:55 -08:00
{
2013-02-27 15:18:48 +01:00
$mes -> addDebug ( " Setup function " . $class_name . " :: " . $method_name . " () NOT found. " );
2012-12-08 12:50:55 -08:00
}
2009-10-20 03:49:28 +00:00
return FALSE ;
2009-12-09 22:38:18 +00:00
}
2009-10-20 03:49:28 +00:00
}
else
{
2012-12-08 01:31:00 -08:00
// $mes->add("Setup Class ".$class_name." NOT found.", E_MESSAGE_DEBUG);
2009-10-20 03:49:28 +00:00
return FALSE ;
2009-12-09 22:38:18 +00:00
}
2009-10-20 03:49:28 +00:00
}
2020-12-18 09:39:02 -08:00
// else
// {
2012-12-08 01:31:00 -08:00
//$mes->add("Optional Setup File NOT Found ".$path."_setup.php ", E_MESSAGE_DEBUG);
2020-12-18 09:39:02 -08:00
// }
2009-10-20 03:49:28 +00:00
2009-12-09 22:38:18 +00:00
return FALSE ; // IMPORTANT.
2008-02-01 14:11:27 +00:00
}
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
/* @ deprecated
// @deprecated - See XMLPrefs();
2010-06-23 10:21:21 +00:00
function parse_prefs ( $pref_array , $mode = 'simple' )
2008-02-01 18:09:02 +00:00
{
$ret = array ();
2010-06-23 10:21:21 +00:00
if ( ! isset ( $pref_array [ 0 ]))
2008-02-01 18:09:02 +00:00
{
$pref_array = array ( $pref_array );
}
2010-06-23 10:21:21 +00:00
if ( is_array ( $pref_array ))
2008-02-01 18:09:02 +00:00
{
2010-06-23 10:21:21 +00:00
foreach ( $pref_array as $k => $p )
2008-02-01 18:09:02 +00:00
{
2009-07-14 03:18:17 +00:00
$attrib = $p [ '@attributes' ];
2010-06-23 10:21:21 +00:00
if ( isset ( $attrib [ 'type' ]) && $attrib [ 'type' ] == 'array' )
2008-02-01 18:09:02 +00:00
{
2009-07-14 03:18:17 +00:00
$name = $attrib [ 'name' ];
$tmp = $this -> parse_prefs ( $pref_array [ $k ][ 'key' ]);
$ret [ 'all' ][ $name ] = $tmp [ 'all' ];
$ret [ 'active' ][ $name ] = $tmp [ 'active' ];
$ret [ 'inactive' ][ $name ] = $tmp [ 'inactive' ];
2008-02-01 18:09:02 +00:00
}
else
{
2009-07-14 03:18:17 +00:00
$ret [ 'all' ][ $attrib [ 'name' ]] = $attrib [ 'value' ];
2010-06-23 10:21:21 +00:00
if ( ! isset ( $attrib [ 'active' ]) || $attrib [ 'active' ] == 'true' )
2009-07-14 03:18:17 +00:00
{
$ret [ 'active' ][ $attrib [ 'name' ]] = $attrib [ 'value' ];
}
else
{
$ret [ 'inactive' ][ $attrib [ 'name' ]] = $attrib [ 'value' ];
}
2008-02-01 18:09:02 +00:00
}
}
}
return $ret ;
}
2008-12-05 14:18:51 +00:00
2017-01-26 15:37:42 -08:00
*/
2008-01-28 02:49:50 +00:00
function install_plugin_php ( $id )
2008-01-26 05:19:59 +00:00
{
2009-10-22 04:14:45 +00:00
$function = 'install' ;
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
2009-10-22 04:14:45 +00:00
$mes = e107 :: getMessage ();
2009-12-09 22:38:18 +00:00
$mySQLprefix = MPREFIX ; // Fix for some plugin.php files.
2017-01-26 15:37:42 -08:00
$this -> log ( " Running Legacy Plugin: " . $function );
2014-01-20 06:20:58 -08:00
if ( is_array ( $id ))
{
$plug = $id ;
$id = $plug [ 'plugin_id' ];
}
else
{
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $id );
2014-01-20 06:20:58 -08:00
}
2008-02-01 14:11:27 +00:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2008-01-28 02:49:50 +00:00
2007-05-07 13:38:34 +00:00
$plug [ 'plug_action' ] = 'install' ;
2006-12-02 04:36:16 +00:00
2009-10-22 04:14:45 +00:00
$this -> parse_plugin_php ( $plug [ 'plugin_path' ]);
$plug_vars = $this -> plug_vars ;
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
$eplug_folder = '' ;
$text = '' ;
2009-07-14 03:18:17 +00:00
include ( $_path . 'plugin.php' );
2008-01-26 05:19:59 +00:00
$func = $eplug_folder . '_install' ;
if ( function_exists ( $func ))
2008-01-20 15:01:19 +00:00
{
2008-01-26 05:19:59 +00:00
$text .= call_user_func ( $func );
}
2006-12-02 04:36:16 +00:00
2017-01-26 15:37:42 -08:00
if ( ! empty ( $eplug_tables ) && is_array ( $eplug_tables ))
2008-01-26 05:19:59 +00:00
{
$result = $this -> manage_tables ( 'add' , $eplug_tables );
2017-01-26 15:37:42 -08:00
if ( $result === true )
2008-01-20 15:01:19 +00:00
{
2008-01-26 05:19:59 +00:00
$text .= EPL_ADLAN_19 . '<br />' ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Tables added " );
2013-02-27 15:18:48 +01:00
$mes -> addSuccess ( EPL_ADLAN_19 );
}
2008-01-26 05:19:59 +00:00
else
2008-01-20 15:01:19 +00:00
{
2017-01-26 15:37:42 -08:00
$this -> log ( " Unable to create tables for this plugin. " ); // NO LANS - debug info!
2013-02-27 15:18:48 +01:00
$mes -> addError ( EPL_ADLAN_18 );
}
2008-01-26 05:19:59 +00:00
}
2006-12-02 04:36:16 +00:00
2010-06-23 10:21:21 +00:00
/* if ( is_array ( $eplug_prefs ))
{
$this -> manage_prefs ( 'add' , $eplug_prefs );
$text .= EPL_ADLAN_8 . '<br />' ;
} */
if ( varset ( $plug_vars [ 'mainPrefs' ])) //Core pref items <mainPrefs>
2009-10-22 04:14:45 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlPrefs ( 'core' , $function , $plug_vars [ 'mainPrefs' ]);
2017-01-26 15:37:42 -08:00
$this -> log ( " Prefs added " );
//$text .= EPL_ADLAN_8.'<br />';
2009-12-09 22:38:18 +00:00
}
2017-01-26 15:37:42 -08:00
if ( ! empty ( $eplug_array_pref ) && is_array ( $eplug_array_pref ))
2008-01-26 05:19:59 +00:00
{
2010-06-23 10:21:21 +00:00
foreach ( $eplug_array_pref as $key => $val )
2008-01-20 15:01:19 +00:00
{
2008-01-26 05:19:59 +00:00
$this -> manage_plugin_prefs ( 'add' , $key , $eplug_folder , $val );
2006-12-02 04:36:16 +00:00
}
2017-01-26 15:37:42 -08:00
$this -> log ( " Adding Prefs: " . print_r ( $eplug_array_pref , true ));
2008-01-26 05:19:59 +00:00
}
2006-12-02 04:36:16 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'siteLinks' ]))
2008-01-26 05:19:59 +00:00
{
2015-02-06 00:14:55 -08:00
$this -> XmlSiteLinks ( $function , $plug_vars );
2008-01-26 05:19:59 +00:00
}
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( varset ( $plug_vars [ 'userClasses' ]))
2009-10-22 04:14:45 +00:00
{
2010-06-23 10:21:21 +00:00
$this -> XmlUserClasses ( $function , $plug_vars [ 'userClasses' ]);
2009-12-09 22:38:18 +00:00
}
2006-12-02 04:36:16 +00:00
2010-06-23 10:21:21 +00:00
$this -> manage_search ( 'add' , $eplug_folder );
2008-01-26 05:19:59 +00:00
2010-06-23 10:21:21 +00:00
$this -> manage_notify ( 'add' , $eplug_folder );
2006-12-02 04:36:16 +00:00
2021-01-18 18:10:00 -08:00
$this -> addonMenu ( $plug_vars [ 'folder' ], $function , $plug_vars [ 'files' ]);
2017-01-26 15:37:42 -08:00
2008-01-26 05:19:59 +00:00
$eplug_addons = $this -> getAddons ( $eplug_folder );
2006-12-02 04:36:16 +00:00
2013-02-25 01:05:35 -08:00
$sql -> update ( 'plugin' , " plugin_installflag = 1, plugin_addons = ' { $eplug_addons } ' WHERE plugin_id = " . ( int ) $id );
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
$p_installed = e107 :: getPref ( 'plug_installed' , array ()); // load preference;
2009-09-03 22:27:32 +00:00
$p_installed [ $plug [ 'plugin_path' ]] = $plug [ 'plugin_version' ];
2009-12-09 22:38:18 +00:00
2012-01-06 09:49:08 +00:00
e107 :: getConfig ( 'core' ) -> setPref ( 'plug_installed' , $p_installed );
$this -> rebuildUrlConfig ();
e107 :: getConfig ( 'core' ) -> save ();
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
$this -> save_addon_prefs ( 'update' );
2008-01-26 05:19:59 +00:00
$text .= ( isset ( $eplug_done ) ? " <br /> { $eplug_done } " : " <br /> " . LAN_INSTALL_SUCCESSFUL );
2017-01-26 15:37:42 -08:00
if ( ! empty ( $eplug_conffile ))
2009-10-20 03:49:28 +00:00
{
2013-03-05 15:08:23 -08:00
$text .= " <br /><a class='btn btn-primary' href=' " . e_PLUGIN . $eplug_folder . " / " . $eplug_conffile . " '> " . LAN_CONFIGURE . " </a> " ;
2009-10-20 03:49:28 +00:00
}
2006-12-02 04:36:16 +00:00
2015-03-23 11:15:13 +01:00
// Event triggering after plugin installation.
$event = e107 :: getEvent ();
$event -> trigger ( 'admin_plugin_install' , $plug );
2008-01-26 05:19:59 +00:00
return $text ;
}
2008-01-20 15:01:19 +00:00
2008-01-26 05:19:59 +00:00
/**
2014-01-20 06:20:58 -08:00
* BC Alias for install ();
*/
public function install_plugin ( $id )
{
global $sysprefs , $mySQLprefix ;
return $this -> install ( $id );
}
2014-05-22 14:54:56 -07:00
/**
* Refresh Plugin Info , Install flag , e_xxx , ignore existing tables . etc .
*
* @ param int $dir - plugin folder .
*/
function refresh ( $dir )
{
if ( empty ( $dir ))
{
2017-01-21 08:45:33 -08:00
return null ;
2014-05-22 14:54:56 -07:00
}
global $sysprefs , $mySQLprefix ;
2020-12-31 08:01:34 -08:00
$text = '' ;
2014-05-22 14:54:56 -07:00
$ns = e107 :: getRender ();
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $dir );
2014-05-22 14:54:56 -07:00
2021-01-17 20:31:25 -08:00
// $this->options = array('nolinks'=>true);
2014-05-22 14:54:56 -07:00
if ( ! is_array ( $plug ))
{
2017-01-21 08:45:33 -08:00
return " ' { $dir } ' is missing from the plugin db table " ;
2014-05-22 14:54:56 -07:00
}
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
if ( file_exists ( $_path . 'plugin.xml' ))
{
2016-04-30 12:02:02 -07:00
$this -> install_plugin_xml ( $plug , 'refresh' );
2014-05-22 14:54:56 -07:00
}
else
{
2016-04-30 12:02:02 -07:00
e107 :: getMessage () -> addDebug ( " Missing xml file at : " . $_path . " plugin.xml " );
2014-05-22 14:54:56 -07:00
$text = EPL_ADLAN_21 ;
}
2016-04-30 12:02:02 -07:00
e107 :: getMessage () -> addDebug ( " Running Refresh of " . $_path );
2014-05-29 14:15:55 -07:00
$this -> save_addon_prefs ();
2017-02-03 20:18:45 -08:00
e107 :: getPlug () -> clearCache ();
2014-05-22 14:54:56 -07:00
return $text ;
}
2014-01-20 06:20:58 -08:00
/**
* Installs a plugin by ID or folder name
2010-06-23 10:21:21 +00:00
*
* @ param int $id
2014-01-20 06:20:58 -08:00
* @ param array $options ( currently only 'nolinks' - set to true to prevent sitelink creation during install )
2010-06-23 10:21:21 +00:00
*/
2014-01-20 06:20:58 -08:00
function install ( $id , $options = array ())
2008-01-26 05:19:59 +00:00
{
2013-02-27 15:18:48 +01:00
global $sysprefs , $mySQLprefix ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Running " . __METHOD__ );
2013-02-27 15:18:48 +01:00
$ns = e107 :: getRender ();
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
$tp = e107 :: getParser ();
2014-01-20 06:20:58 -08:00
$this -> options = $options ;
2008-01-26 05:19:59 +00:00
2012-01-01 10:51:05 +00:00
$text = '' ;
2018-11-02 10:07:59 -05:00
e107 :: getPlug () -> clearCache ();
2008-01-26 05:19:59 +00:00
// install plugin ...
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $id );
2018-11-02 10:07:59 -05:00
// XXX: The code below does not actually check if the plugin is in the database table.
2014-01-20 06:20:58 -08:00
if ( ! is_array ( $plug ))
{
2018-08-03 16:36:21 -07:00
$message = $id . " is missing from the plugin db table " ;
$this -> log ( $message );
return $message ;
2014-01-20 06:20:58 -08:00
}
2018-11-02 10:07:59 -05:00
// XXX: The code above does not actually check if the plugin is in the database table.
2014-01-20 06:20:58 -08:00
2017-01-26 15:37:42 -08:00
$plug [ 'plug_action' ] = ! empty ( $options [ 'function' ]) ? $options [ 'function' ] : 'install' ;
2008-12-05 14:18:51 +00:00
2009-09-17 01:47:20 +00:00
if ( ! vartrue ( $plug [ 'plugin_installflag' ]))
2008-01-26 05:19:59 +00:00
{
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2017-01-26 15:37:42 -08:00
$this -> log ( " Installing: " . $plug [ 'plugin_path' ]);
2014-01-20 06:20:58 -08:00
2010-06-23 10:21:21 +00:00
if ( file_exists ( $_path . 'plugin.xml' ))
2008-01-26 05:19:59 +00:00
{
2014-01-20 06:20:58 -08:00
$text = $this -> install_plugin_xml ( $plug , 'install' );
2008-01-26 05:19:59 +00:00
}
2010-06-23 10:21:21 +00:00
elseif ( file_exists ( $_path . 'plugin.php' ))
2008-01-26 05:19:59 +00:00
{
2014-01-20 06:20:58 -08:00
$text = $this -> install_plugin_php ( $plug );
2008-01-20 15:01:19 +00:00
}
}
else
{
2006-12-02 04:36:16 +00:00
$text = EPL_ADLAN_21 ;
2014-01-20 06:20:58 -08:00
2006-12-02 04:36:16 +00:00
}
2017-01-26 15:37:42 -08:00
$this -> log ( " Installation completed " ); // no LANs
2017-02-03 20:18:45 -08:00
e107 :: getPlug () -> clearCache ();
2008-02-02 22:04:18 +00:00
return $text ;
2006-12-02 04:36:16 +00:00
}
2012-12-23 15:00:15 +00:00
2022-04-04 10:54:24 -07:00
/**
* @ param $id
* @ param $options
* @ return false | string
*/
2017-01-26 15:37:42 -08:00
public function uninstall ( $id , $options = array ())
{
$pref = e107 :: getPref ();
2020-12-22 09:36:02 -08:00
$admin_log = e107 :: getLog ();
2017-01-26 15:37:42 -08:00
$plugin = e107 :: getPlugin ();
$tp = e107 :: getParser ();
$sql = e107 :: getDb ();
2018-07-22 09:36:23 -07:00
$plug = e107plugin :: getPluginRecord ( $id );
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
$this -> log ( " Uninstalling : " . $plug [ 'plugin_path' ] . " with options: " . print_r ( $options , true ));
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
$this -> log ( " e107plugin::getPluginRecord() returned: " . print_r ( $plug , true ));
2018-08-05 15:08:54 -07:00
2017-01-26 15:37:42 -08:00
// Check if plugin is being used by another plugin before uninstalling it.
2020-01-17 17:11:26 +01:00
if ( isset ( $plug [ 'plugin_path' ]))
2017-01-26 15:37:42 -08:00
{
if ( $this -> isUsedByAnotherPlugin ( $plug [ 'plugin_path' ]))
{
$this -> action = 'installed' ; // Render plugin list.
return false ;
}
}
2020-01-17 17:11:26 +01:00
$text = '' ;
//Uninstall Plugin
$eplug_folder = $plug [ 'plugin_path' ];
if ( $plug [ 'plugin_installflag' ] == true )
{
$this -> log ( " plugin_installflag = true, proceeding to uninstall " );
2018-08-05 15:08:54 -07:00
2020-01-17 17:11:26 +01:00
$_path = e_PLUGIN . $plug [ 'plugin_path' ] . '/' ;
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
if ( file_exists ( $_path . 'plugin.xml' ))
{
2021-01-19 18:52:56 -08:00
if ( isset ( $_POST [ 'uninstall_confirm' ]))
{
unset ( $_POST [ 'uninstall_confirm' ]);
}
2020-01-17 17:11:26 +01:00
$this -> install_plugin_xml ( $plug , 'uninstall' , $options ); //$_POST must be used.
}
else
{ // Deprecated - plugin uses plugin.php
$eplug_table_names = null ;
$eplug_prefs = null ;
$eplug_comment_ids = null ;
$eplug_array_pref = null ;
$eplug_menu_name = null ;
$eplug_link = null ;
$eplug_link_url = null ;
$eplug_link_name = null ;
$eplug_userclass = null ;
$eplug_version = null ;
include ( e_PLUGIN . $plug [ 'plugin_path' ] . '/plugin.php' );
$func = $eplug_folder . '_uninstall' ;
if ( function_exists ( $func ))
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
$text .= call_user_func ( $func );
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
if ( ! empty ( $options [ 'delete_tables' ]))
{
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
if ( is_array ( $eplug_table_names ))
{
$result = $this -> manage_tables ( 'remove' , $eplug_table_names );
if ( $result !== TRUE )
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
$text .= EPL_ADLAN_27 . ' <b>' . MPREFIX . $result . '</b> - ' . EPL_ADLAN_30 . '<br />' ;
$this -> log ( " Unable to delete table. " ); // No LANS
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
else
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
$text .= EPL_ADLAN_28 . " <br /> " ;
$this -> log ( " Deleting tables. " ); // NO LANS
2017-01-26 15:37:42 -08:00
}
}
2020-01-17 17:11:26 +01:00
}
else
{
$text .= EPL_ADLAN_49 . " <br /> " ;
$this -> log ( " Tables left intact by request. " ); // No LANS
}
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
if ( is_array ( $eplug_prefs ))
{
$this -> manage_prefs ( 'remove' , $eplug_prefs );
$text .= EPL_ADLAN_29 . " <br /> " ;
}
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
if ( is_array ( $eplug_comment_ids ))
{
$text .= ( $this -> manage_comments ( 'remove' , $eplug_comment_ids )) ? EPL_ADLAN_50 . " <br /> " : " " ;
}
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
if ( is_array ( $eplug_array_pref ))
{
foreach ( $eplug_array_pref as $key => $val )
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
$this -> manage_plugin_prefs ( 'remove' , $key , $eplug_folder , $val );
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
}
/*
if ( $eplug_menu_name )
{
$sql -> delete ( 'menus' , " menu_name=' { $eplug_menu_name } ' " );
} */
$folderFiles = scandir ( e_PLUGIN . $plug [ 'plugin_path' ]);
2021-01-18 18:10:00 -08:00
$this -> addonMenu ( $eplug_folder , 'uninstall' , $folderFiles );
2020-01-17 17:11:26 +01:00
if ( $eplug_link )
{
$this -> manage_link ( 'remove' , $eplug_link_url , $eplug_link_name );
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
if ( $eplug_userclass )
{
$this -> manage_userclass ( 'remove' , $eplug_userclass );
}
2017-01-26 15:37:42 -08:00
2020-01-17 17:11:26 +01:00
$sql -> update ( 'plugin' , " plugin_installflag=0, plugin_version=' { $eplug_version } ' WHERE plugin_path=' { $eplug_folder } ' " );
$this -> manage_search ( 'remove' , $eplug_folder );
$this -> manage_notify ( 'remove' , $eplug_folder );
// it's done inside install_plugin_xml(), required only here
if ( isset ( $pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]]))
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
unset ( $pref [ 'plug_installed' ][ $plug [ 'plugin_path' ]]);
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
e107 :: getConfig ( 'core' ) -> setPref ( $pref );
$this -> rebuildUrlConfig ();
e107 :: getConfig ( 'core' ) -> save ( false , true , false );
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
$logInfo = deftrue ( $plug [ 'plugin_name' ], $plug [ 'plugin_name' ]) . " v " . $plug [ 'plugin_version' ] . " ( { e_PLUGIN} " . $plug [ 'plugin_path' ] . " ) " ;
e107 :: getLog () -> add ( 'PLUGMAN_03' , $logInfo , E_LOG_INFORMATIVE , '' );
}
else
{
$this -> log ( " plugin_installflag = false, uninstall skipped. " );
}
if ( ! empty ( $options [ 'delete_files' ]) && ( $plug [ 'plugin_installflag' ] == true ))
{
if ( ! empty ( $eplug_folder ))
2017-01-26 15:37:42 -08:00
{
2020-01-17 17:11:26 +01:00
$result = e107 :: getFile () -> rmtree ( e_PLUGIN . $eplug_folder );
e107 :: getDb () -> delete ( 'plugin' , " plugin_path=' " . $eplug_folder . " ' " );
$text .= ( $result ? '<br />' . EPL_ADLAN_86 . e_PLUGIN . $eplug_folder : '<br />' . EPL_ADLAN_87 . '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32 );
2017-01-26 15:37:42 -08:00
}
2020-01-17 17:11:26 +01:00
}
else
{
$text .= '<br />' . EPL_ADLAN_31 . ' <b>' . e_PLUGIN . $eplug_folder . '</b> ' . EPL_ADLAN_32 ;
}
2017-01-26 15:37:42 -08:00
2018-08-05 15:08:54 -07:00
e107 :: getPlug () -> clearCache () -> buildAddonPrefLists ();
2021-01-02 16:34:11 +01:00
e107 :: getSession () -> clear ( 'addons-update-status' );
2018-08-05 15:08:54 -07:00
2020-01-17 17:11:26 +01:00
// $this->save_addon_prefs('update');
2017-01-26 15:37:42 -08:00
$this -> log ( " Uninstall completed " );
2018-08-05 15:08:54 -07:00
2017-01-26 15:37:42 -08:00
return $text ;
}
2017-12-16 11:31:47 -08:00
/**
2012-12-23 15:00:15 +00:00
* scan the plugin table and create path - array - prefs for each addon .
2017-12-16 11:31:47 -08:00
* @ deprecated Replaced by eplug :: refreshAddonPrefList ()
2012-12-23 15:00:15 +00:00
* @ param string $mode = install | upgrade | refresh | uninstall - defines the intent of the call
*
* 'upgrade' and 'refresh' are very similar in intent , and often take the same actions :
* 'upgrade' signals a possible change to the installed list of plugins - usually an upgrade
* 'refresh' validates the stored data for existing plugins , recreating any that has gone missing
*/
function save_addon_prefs ( $mode = 'upgrade' )
2009-12-09 22:38:18 +00:00
{
2017-02-07 08:57:18 -08:00
$this -> log ( 'Running save_addon_prefs(' . $mode . ')' );
2018-08-03 16:36:21 -07:00
// e107::getPlug()->buildAddonPrefLists(); // XXX TODO Breaks plugin installation in most cases.
// return;
2015-01-29 13:09:22 -08:00
2009-09-03 22:27:32 +00:00
$sql = e107 :: getDb ();
2009-09-06 20:04:04 +00:00
$core = e107 :: getConfig ( 'core' );
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
foreach ( $this -> plugin_addons as $var ) // clear all existing prefs.
2009-12-09 22:38:18 +00:00
2009-09-12 13:16:56 +00:00
{
2010-06-23 10:21:21 +00:00
$core -> update ( $var . '_list' , " " );
2009-09-12 13:16:56 +00:00
}
2013-02-11 14:25:59 +02:00
// reset
$core -> set ( 'bbcode_list' , array ())
2013-02-27 15:18:48 +01:00
-> set ( 'shortcode_legacy_list' , array ())
-> set ( 'shortcode_list' , array ());
2013-02-11 14:25:59 +02:00
2010-06-23 10:21:21 +00:00
$query = " SELECT * FROM #plugin WHERE plugin_addons !='' ORDER BY plugin_path ASC " ;
2009-12-09 22:38:18 +00:00
2013-02-22 15:43:58 -08:00
if ( $sql -> gen ( $query ))
2006-12-02 04:36:16 +00:00
{
2013-02-25 01:05:35 -08:00
while ( $row = $sql -> fetch ())
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
$is_installed = ( $row [ 'plugin_installflag' ] == 1 );
$tmp = explode ( " , " , $row [ 'plugin_addons' ]);
2006-12-02 04:36:16 +00:00
$path = $row [ 'plugin_path' ];
2013-02-11 14:25:59 +02:00
2008-01-20 15:01:19 +00:00
if ( $is_installed )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
foreach ( $tmp as $val )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
if ( strpos ( $val , 'e_' ) === 0 )
2008-01-20 15:01:19 +00:00
{
2009-09-06 20:04:04 +00:00
// $addpref[$val."_list"][$path] = $path;
2010-06-23 10:21:21 +00:00
$core -> setPref ( $val . '_list/' . $path , $path );
2008-01-20 15:01:19 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
2009-12-09 22:38:18 +00:00
2008-01-20 15:01:19 +00:00
// search for .bb and .sc files.
2013-02-11 14:25:59 +02:00
$scl_array = array ();
2006-12-02 04:36:16 +00:00
$sc_array = array ();
$bb_array = array ();
$sql_array = array ();
2010-06-23 10:21:21 +00:00
foreach ( $tmp as $adds )
2006-12-02 04:36:16 +00:00
{
2013-02-11 14:25:59 +02:00
// legacy shortcodes - plugin root *.sc files
if ( substr ( $adds , - 3 ) === " .sc " )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
$sc_name = substr ( $adds , 0 , - 3 ); // remove the .sc
2013-02-11 14:25:59 +02:00
if ( $is_installed )
{
$scl_array [ $sc_name ] = " 0 " ; // default userclass = e_UC_PUBLIC
}
else
{
$scl_array [ $sc_name ] = e_UC_NOBODY ; // register shortcode, but disable it
}
}
// new shortcodes location - shortcodes/single/*.php
2021-01-24 17:00:02 -08:00
elseif ( strpos ( $adds , " sc_ " ) === 0 )
2013-02-11 14:25:59 +02:00
{
$sc_name = substr ( substr ( $adds , 3 ), 0 , - 4 ); // remove the sc_ and .php
2007-07-18 20:46:42 +00:00
if ( $is_installed )
{
2008-01-20 15:01:19 +00:00
$sc_array [ $sc_name ] = " 0 " ; // default userclass = e_UC_PUBLIC
2013-02-11 14:25:59 +02:00
}
2007-07-18 20:46:42 +00:00
else
{
2008-01-20 15:01:19 +00:00
$sc_array [ $sc_name ] = e_UC_NOBODY ; // register shortcode, but disable it
2011-12-10 19:34:08 +00:00
}
2006-12-02 04:36:16 +00:00
}
2011-12-10 19:34:08 +00:00
if ( $is_installed )
{
// simple bbcode
2011-12-10 19:06:19 +00:00
if ( substr ( $adds , - 3 ) == " .bb " )
{
$bb_name = substr ( $adds , 0 , - 3 ); // remove the .bb
$bb_array [ $bb_name ] = " 0 " ; // default userclass.
}
// bbcode class
2021-01-24 17:00:02 -08:00
elseif ( strpos ( $adds , " bb_ " ) === 0 && substr ( $adds , - 4 ) == " .php " )
2011-12-10 19:06:19 +00:00
{
2011-12-10 19:34:08 +00:00
$bb_name = substr ( $adds , 0 , - 4 ); // remove the .php
$bb_name = substr ( $bb_name , 3 );
$bb_array [ $bb_name ] = " 0 " ; // TODO - instance and getPermissions() method
2011-12-10 19:06:19 +00:00
}
2011-12-10 19:34:08 +00:00
}
2006-12-02 04:36:16 +00:00
2010-06-23 10:21:21 +00:00
if ( $is_installed && ( substr ( $adds , - 4 ) == " _sql " ))
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
$core -> setPref ( 'e_sql_list/' . $path , $adds );
2006-12-02 04:36:16 +00:00
}
}
2013-02-11 14:25:59 +02:00
2008-01-20 15:01:19 +00:00
// Build Bbcode list (will be empty if plugin not installed)
2010-06-23 10:21:21 +00:00
if ( count ( $bb_array ) > 0 )
2006-12-02 04:36:16 +00:00
{
ksort ( $bb_array );
2009-10-08 14:47:54 +00:00
$core -> setPref ( 'bbcode_list/' . $path , $bb_array );
2006-12-02 04:36:16 +00:00
}
2008-01-20 15:01:19 +00:00
// Build shortcode list - do if uninstalled as well
2013-02-11 14:25:59 +02:00
if ( count ( $scl_array ) > 0 )
{
ksort ( $scl_array );
$core -> setPref ( 'shortcode_legacy_list/' . $path , $scl_array );
}
2010-06-23 10:21:21 +00:00
if ( count ( $sc_array ) > 0 )
2007-05-07 13:38:34 +00:00
{
2008-01-20 15:01:19 +00:00
ksort ( $sc_array );
2010-06-23 10:21:21 +00:00
$core -> setPref ( 'shortcode_list/' . $path , $sc_array );
2006-12-02 04:36:16 +00:00
}
}
}
2015-08-24 17:39:28 -07:00
$core -> save ( FALSE , false , false );
2020-12-18 09:39:02 -08:00
/*
2010-06-23 10:21:21 +00:00
if ( $this -> manage_icons ())
2009-07-16 02:55:19 +00:00
{
2010-06-23 10:21:21 +00:00
// echo 'IT WORKED';
}
2009-07-16 02:55:19 +00:00
else
{
2010-06-23 10:21:21 +00:00
// echo "didn't work!";
2020-12-18 09:39:02 -08:00
} */
2018-08-05 15:08:54 -07:00
return null ;
2006-12-02 04:36:16 +00:00
}
2022-04-04 10:54:24 -07:00
/**
* @ return array
*/
2016-04-10 18:47:40 -07:00
public function getAddonsList ()
{
$list = array_diff ( $this -> plugin_addons , $this -> plugin_addons_deprecated );
sort ( $list );
return $list ;
}
2022-04-04 10:54:24 -07:00
/**
* @ param $v
* @ return mixed | string | null
*/
2016-04-10 18:47:40 -07:00
public function getAddonsDiz ( $v )
{
if ( ! empty ( $this -> plugin_addons_diz [ $v ]))
{
return $this -> plugin_addons_diz [ $v ];
}
return null ;
}
2008-01-20 15:01:19 +00:00
// return a list of available plugin addons for the specified plugin. e_xxx etc.
2007-02-11 20:16:25 +00:00
// $debug = TRUE - prints diagnostics
// $debug = 'check' - checks each file found for php tags - prints 'pass' or 'fail'
2022-04-04 10:54:24 -07:00
/**
* @ param $plugin_path
* @ param $debug
* @ return string
*/
2010-06-23 10:21:21 +00:00
function getAddons ( $plugin_path , $debug = FALSE )
2007-02-11 20:16:25 +00:00
{
2009-09-06 20:04:04 +00:00
$fl = e107 :: getFile ();
2013-02-27 15:18:48 +01:00
$mes = e107 :: getMessage ();
2009-12-09 22:38:18 +00:00
2008-01-20 15:01:19 +00:00
$p_addons = array ();
2009-09-21 21:53:38 +00:00
2016-04-10 18:47:40 -07:00
2010-06-23 10:21:21 +00:00
foreach ( $this -> plugin_addons as $addon ) //Find exact matches only.
2009-12-09 22:38:18 +00:00
{
// if(preg_match("#^(e_.*)\.php$#", $f['fname'], $matches))
2009-09-21 21:53:38 +00:00
2010-06-23 10:21:21 +00:00
$addonPHP = $addon . " .php " ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( is_readable ( e_PLUGIN . $plugin_path . " / " . $addonPHP ))
{
if ( $debug === 'check' )
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$passfail = '' ;
$file_text = file_get_contents ( e_PLUGIN . $plugin_path . " / " . $addonPHP );
2021-01-24 17:00:02 -08:00
if (( strpos ( $file_text , '<' . '?php' ) !== 0 ) || (( substr ( $file_text , - 2 , 2 ) != '?' . '>' ) && ( strrpos ( $file_text , '?' . '>' ) !== FALSE )))
2008-01-20 15:01:19 +00:00
{
2010-06-23 10:21:21 +00:00
$passfail = '<b>fail</b>' ;
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
else
{
$passfail = 'pass' ;
}
echo $plugin_path . " / " . $addon . " .php - " . $passfail . " <br /> " ;
2008-01-20 15:01:19 +00:00
}
2010-06-23 10:21:21 +00:00
// $mes->add('Detected addon: <b>'.$addon.'</b>', E_MESSAGE_DEBUG);
$p_addons [] = $addon ;
}
2006-12-02 04:36:16 +00:00
}
// Grab List of Shortcodes & BBcodes
2013-02-11 14:25:59 +02:00
$shortcodeLegacyList = $fl -> get_files ( e_PLUGIN . $plugin_path , '\.sc$' , " standard " , 1 );
$shortcodeList = $fl -> get_files ( e_PLUGIN . $plugin_path . '/shortcodes/single' , '\.php$' , " standard " , 1 );
2011-12-10 19:06:19 +00:00
$bbcodeList = $fl -> get_files ( e_PLUGIN . $plugin_path , '\.bb$' , " standard " , 1 );
$bbcodeClassList = $fl -> get_files ( e_PLUGIN . $plugin_path , '^bb_(.*)\.php$' , " standard " , 1 );
$bbcodeList = array_merge ( $bbcodeList , $bbcodeClassList );
$sqlList = $fl -> get_files ( e_PLUGIN . $plugin_path , '_sql\.php$' , " standard " , 1 );
2012-12-12 18:46:34 -08:00
2006-12-02 04:36:16 +00:00
// Search Shortcodes
2013-02-11 14:25:59 +02:00
foreach ( $shortcodeLegacyList as $sc )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
if ( is_readable ( e_PLUGIN . $plugin_path . " / " . $sc [ 'fname' ]))
2006-12-02 04:36:16 +00:00
{
$p_addons [] = $sc [ 'fname' ];
}
}
2013-02-11 14:25:59 +02:00
foreach ( $shortcodeList as $sc )
{
if ( is_readable ( e_PLUGIN . $plugin_path . " /shortcodes/single/ " . $sc [ 'fname' ]))
{
$p_addons [] = 'sc_' . $sc [ 'fname' ];
}
}
2006-12-02 04:36:16 +00:00
2008-01-20 15:01:19 +00:00
// Search Bbcodes.
2010-06-23 10:21:21 +00:00
foreach ( $bbcodeList as $bb )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
if ( is_readable ( e_PLUGIN . $plugin_path . " / " . $bb [ 'fname' ]))
2006-12-02 04:36:16 +00:00
{
$p_addons [] = $bb [ 'fname' ];
}
}
2008-01-20 15:01:19 +00:00
// Search _sql files.
2010-06-23 10:21:21 +00:00
foreach ( $sqlList as $esql )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
if ( is_readable ( e_PLUGIN . $plugin_path . " / " . $esql [ 'fname' ]))
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
$fname = str_replace ( " .php " , " " , $esql [ 'fname' ]);
if ( ! in_array ( $fname , $p_addons ))
$p_addons [] = $fname ; // Probably already found - avoid duplication
}
2006-12-02 04:36:16 +00:00
}
2010-06-23 10:21:21 +00:00
if ( $debug == true )
2006-12-02 04:36:16 +00:00
{
2010-06-23 10:21:21 +00:00
echo $plugin_path . " = " . implode ( " , " , $p_addons ) . " <br /> " ;
2006-12-02 04:36:16 +00:00
}
2018-07-20 12:58:49 -07:00
$this -> log ( " Detected Addons: " . print_r ( $p_addons , true ));
2017-02-07 08:57:18 -08:00
2010-06-23 10:21:21 +00:00
return implode ( " , " , $p_addons );
2006-12-02 04:36:16 +00:00
}
2013-05-04 15:42:55 -07:00
/**
* Check Plugin Addon for errors .
2020-12-18 09:39:02 -08:00
* @ return array | int array or numeric . 0 = OK , 1 = Fail , 2 = inaccessible
2013-05-04 15:42:55 -07:00
*/
function checkAddon ( $plugin_path , $e_xxx )
{
2010-06-23 10:21:21 +00:00
if ( is_readable ( e_PLUGIN . $plugin_path . " / " . $e_xxx . " .php " ))
2008-01-20 15:01:19 +00:00
{
2013-05-04 15:42:55 -07:00
$content = file_get_contents ( e_PLUGIN . $plugin_path . " / " . $e_xxx . " .php " );
}
else
{
return 2 ;
}
if ( substr ( $e_xxx , - 4 , 4 ) == '_sql' )
{
if ( strpos ( $content , 'INSERT INTO' ) !== false )
2009-10-29 13:36:27 +00:00
{
2013-05-04 15:42:55 -07:00
return array ( 'type' => 'error' , 'msg' => " INSERT sql commands are not permitted here. Use a " . $plugin_path . " _setup.php file instead. " );
2009-10-29 13:36:27 +00:00
}
2013-05-04 15:42:55 -07:00
else
{
return 0 ;
}
}
// Generic markup check
2021-01-24 17:00:02 -08:00
if (( strpos ( $content , '<' . '?php' ) !== 0 ) || (( substr ( $content , - 2 , 2 ) != '?' . '>' ) && ( strrpos ( $content , '?' . '>' ) !== FALSE )))
2013-05-04 15:42:55 -07:00
{
return 1 ;
}
if ( $e_xxx == 'e_meta' && strpos ( $content , '<script' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Contains script tags. Use e_header.php with the e107::js() function instead. " );
}
if ( $e_xxx == 'e_latest' && strpos ( $content , '<div' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Using deprecated method. See e_latest.php in the forum plugin for an example. " );
2007-02-14 21:17:42 +00:00
}
2013-05-04 15:42:55 -07:00
if ( $e_xxx == 'e_status' && strpos ( $content , '<div' ) !== false )
{
return array ( 'type' => 'warning' , 'msg' => " Using deprecated method. See e_status.php in the forum plugin for an example. " );
}
return 0 ;
2007-02-14 21:17:42 +00:00
}
2008-01-26 05:19:59 +00:00
2008-08-09 16:49:58 +00:00
// Entry point to read plugin configuration data
2022-04-04 10:54:24 -07:00
/**
* @ param $plugName
* @ param $force
* @ return bool | string
*/
2010-06-23 10:21:21 +00:00
function parse_plugin ( $plugName , $force = false )
2008-01-26 04:47:27 +00:00
{
2009-08-31 02:00:51 +00:00
$ret = " " ;
2009-12-09 22:38:18 +00:00
2010-06-23 10:21:21 +00:00
if ( isset ( $this -> parsed_plugin [ $plugName ]) && $force != true )
2008-01-28 02:49:50 +00:00
{
2008-12-10 22:39:43 +00:00
$this -> plug_vars = $this -> parsed_plugin [ $plugName ];
2008-01-28 02:49:50 +00:00
return true ;
}
2010-06-23 10:21:21 +00:00
unset ( $this -> parsed_plugin [ $plugName ]); // In case forced parsing which fails
if ( file_exists ( e_PLUGIN . $plugName . '/plugin.xml' ))
2008-01-26 04:47:27 +00:00
{
2008-12-10 22:39:43 +00:00
$ret = $this -> parse_plugin_xml ( $plugName );
2008-01-26 04:47:27 +00:00
}
2010-06-23 10:21:21 +00:00
elseif ( file_exists ( e_PLUGIN . $plugName . '/plugin.php' ))
2008-01-26 04:47:27 +00:00
{
2008-12-10 22:39:43 +00:00
$ret = $this -> parse_plugin_php ( $plugName );
2008-01-26 04:47:27 +00:00
}
2010-06-23 10:21:21 +00:00
if ( $ret == true )
2008-01-28 02:49:50 +00:00
{
2008-12-10 22:39:43 +00:00
$this -> parsed_plugin [ $plugName ] = $this -> plug_vars ;
2008-01-28 02:49:50 +00:00
}
2009-12-09 22:38:18 +00:00
2008-01-28 02:49:50 +00:00
return $ret ;
2008-01-26 04:47:27 +00:00
}
2011-05-18 08:58:35 +00:00
// return the Icon of the
2022-04-04 10:54:24 -07:00
/**
* @ param $plugName
* @ param $size
* @ param $defaultOverride
* @ return false | mixed | string | null
*/
function getIcon ( $plugName = '' , $size = 32 , $defaultOverride = false )
2011-05-18 08:58:35 +00:00
{
2016-11-01 16:42:47 -07:00
if ( ! $plugName ) return false ;
2011-05-18 08:58:35 +00:00
2014-01-22 06:10:44 -08:00
$tp = e107 :: getParser ();
2011-05-18 08:58:35 +00:00
if ( ! isset ( $this -> parsed_plugin [ $plugName ]))
{
2016-11-01 16:42:47 -07:00
$this -> parse_plugin ( $plugName , true );
2011-05-18 08:58:35 +00:00
}
2016-11-01 16:42:47 -07:00
$plug_vars = $this -> parsed_plugin [ $plugName ];
2011-05-18 08:58:35 +00:00
2016-11-01 16:42:47 -07:00
//return print_r($plug_vars,TRUE);
2011-05-18 08:58:35 +00:00
$sizeArray = array ( 32 => 'icon' , 16 => 'iconSmall' );
2014-01-22 06:10:44 -08:00
$default = ( $size == 32 ) ? $tp -> toGlyph ( 'e-cat_plugins-32' ) : " <img class='icon S16' src=' " . E_16_CAT_PLUG . " ' alt='' /> " ;
2011-05-18 08:58:35 +00:00
$sz = $sizeArray [ $size ];
2011-08-17 00:49:39 +00:00
$icon_src = e_PLUGIN . $plugName . " / " . $plug_vars [ 'administration' ][ $sz ];
2011-05-18 08:58:35 +00:00
$plugin_icon = $plug_vars [ 'administration' ][ $sz ] ? " <img src=' { $icon_src } ' alt='' class='icon S " . intval ( $size ) . " ' /> " : $default ;
2016-11-01 16:42:47 -07:00
if ( $defaultOverride !== false && $default === $plugin_icon )
{
return $defaultOverride ;
}
2011-05-18 08:58:35 +00:00
return $plugin_icon ;
}
2008-01-26 04:47:27 +00:00
2008-08-09 16:49:58 +00:00
// Called to parse the (deprecated) plugin.php file
2022-04-04 10:54:24 -07:00
/**
* @ param $plugName
* @ return bool
*/
2008-12-10 22:39:43 +00:00
function parse_plugin_php ( $plugName )
2008-01-26 04:47:27 +00:00
{
2009-12-09 22:38:18 +00:00
$tp = e107 :: getParser ();
2016-12-16 12:13:52 -08:00
$sql = e107 :: getDb (); // in case it is used inside plugin.php
2009-12-09 22:38:18 +00:00
2016-05-07 15:33:09 -07:00
$PLUGINS_FOLDER = '{e_PLUGIN}' ; // Could be used in plugin.php file.
2015-03-07 16:31:13 -08:00
$eplug_conffile = null ;
$eplug_table_names = null ;
$eplug_prefs = null ;
$eplug_module = null ;
$eplug_userclass = null ;
$eplug_status = null ;
$eplug_latest = null ;
$eplug_icon = null ;
$eplug_icon_small = null ;
2020-12-18 09:39:02 -08:00
e107 :: getDebug () -> log ( " Legacy Plugin Parse (php): " . $plugName );
2015-03-07 16:31:13 -08:00
2016-12-17 10:58:07 -08:00
ob_start ();
2020-12-18 09:39:02 -08:00
include ( e_PLUGIN . $plugName . '/plugin.php' );
// if (include(e_PLUGIN.$plugName.'/plugin.php'))
// {
2009-12-09 22:38:18 +00:00
//$mes->add("Loading ".e_PLUGIN.$plugName.'/plugin.php', E_MESSAGE_DEBUG);
2020-12-18 09:39:02 -08:00
// }
2016-12-17 10:58:07 -08:00
ob_end_clean ();
2008-01-26 04:47:27 +00:00
$ret = array ();
2010-06-23 10:21:21 +00:00
// $ret['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || is_array($eplug_sc) || is_array($eplug_bb) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest);
2009-12-09 22:38:18 +00:00
2008-12-03 22:29:58 +00:00
$ret [ '@attributes' ][ 'name' ] = varset ( $eplug_name );
2012-08-22 02:45:32 +00:00
$ret [ '@attributes' ][ 'lang' ] = varset ( $eplug_name );
2009-10-22 04:14:45 +00:00
$ret [ '@attributes' ][ 'version' ] = varset ( $eplug_version );
2012-07-24 00:42:17 +00:00
$ret [ '@attributes' ][ 'date' ] = varset ( $eplug_date );
2008-12-03 22:29:58 +00:00
$ret [ '@attributes' ][ 'compatibility' ] = varset ( $eplug_compatible );
2009-10-22 04:14:45 +00:00
$ret [ '@attributes' ][ 'installRequired' ] = ( $eplug_conffile || is_array ( $eplug_table_names ) || is_array ( $eplug_prefs ) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest ) ? 'true' : '' ;
$ret [ '@attributes' ][ 'xhtmlcompliant' ] = vartrue ( $eplug_compliant ) ? 'true' : '' ;
2009-09-21 21:53:38 +00:00
$ret [ 'folder' ] = ( varset ( $eplug_folder )) ? $eplug_folder : $plugName ;
2009-12-09 22:38:18 +00:00
2008-12-03 22:29:58 +00:00
$ret [ 'author' ][ '@attributes' ][ 'name' ] = varset ( $eplug_author );
$ret [ 'author' ][ '@attributes' ][ 'url' ] = varset ( $eplug_url );
$ret [ 'author' ][ '@attributes' ][ 'email' ] = varset ( $eplug_email );
2012-08-22 02:45:32 +00:00
$ret [ 'description' ][ '@value' ] = varset ( $eplug_description );
$ret [ 'description' ][ '@attributes' ][ 'lang' ] = varset ( $eplug_description );
2009-12-09 22:38:18 +00:00
2009-10-22 04:14:45 +00:00
$ret [ 'category' ] = varset ( $eplug_category ) ? $this -> manage_category ( $eplug_category ) : " misc " ;
2008-01-26 04:47:27 +00:00
$ret [ 'readme' ] = varset ( $eplug_readme );
2009-10-22 04:14:45 +00:00
$ret [ 'menuName' ] = varset ( $eplug_menu_name );
2009-12-09 22:38:18 +00:00
2015-02-05 00:02:29 -08:00
if ( ! empty ( $eplug_prefs ) && is_array ( $eplug_prefs ))
2009-10-22 04:14:45 +00:00
{
$c = 0 ;
2015-02-05 00:02:29 -08:00
foreach ( $eplug_prefs as $name => $value )
2009-10-22 04:14:45 +00:00
{
$ret [ 'mainPrefs' ][ 'pref' ][ $c ][ '@attributes' ][ 'name' ] = $name ;
$ret [ 'mainPrefs' ][ 'pref' ][ $c ][ '@value' ] = $value ;
$c ++ ;
}
}
2009-07-09 02:47:17 +00:00
2009-12-09 22:38:18 +00:00
// For BC.
2012-12-19 11:37:45 +01:00
$ret [ 'administration' ][ 'icon' ] = str_replace ( $plugName . " / " , " " , $eplug_icon );
2008-01-26 04:47:27 +00:00
$ret [ 'administration' ][ 'caption' ] = varset ( $eplug_caption );
2012-12-19 11:37:45 +01:00
$ret [ 'administration' ][ 'iconSmall' ] = str_replace ( $plugName . " / " , " " , $eplug_icon_small );
2008-01-26 04:47:27 +00:00
$ret [ 'administration' ][ 'configFile' ] = varset ( $eplug_conffile );
2008-01-26 05:19:59 +00:00
2017-01-26 15:37:42 -08:00
if ( varset ( $eplug_conffile ))
2009-10-22 04:14:45 +00:00
{
2010-06-23 10:21:21 +00:00
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ] = varset ( $eplug_conffile );
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'description' ] = LAN_CONFIGURE ;
2012-12-19 11:37:45 +01:00
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'icon' ] = str_replace ( $plugName . " / " , " " , $eplug_icon );
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'iconSmall' ] = str_replace ( $plugName . " / " , " " , $eplug_icon_small );
2010-06-23 10:21:21 +00:00
$ret [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'primary' ] = 'true' ;
2009-10-22 04:14:45 +00:00
}
2020-12-20 11:50:10 -08:00
if ( ! empty ( $eplug_link ) && varset ( $eplug_link_name ) && varset ( $eplug_link_url ))
2009-10-22 04:14:45 +00:00
{
2010-06-23 10:21:21 +00:00
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ] = $tp -> createConstants ( $eplug_link_url , 1 );
2009-12-09 22:38:18 +00:00
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'perm' ] = varset ( $eplug_link_perms );
2010-06-23 10:21:21 +00:00
$ret [ 'siteLinks' ][ 'link' ][ 0 ][ '@value' ] = varset ( $eplug_link_name );
2009-10-22 04:14:45 +00:00
}
2009-12-09 22:38:18 +00:00
2020-12-20 11:50:10 -08:00
if ( ! empty ( $eplug_userclass ) && ! empty ( $eplug_userclass_description ))
2009-10-22 04:14:45 +00:00
{
$ret [ 'userClasses' ][ 'class' ][ 0 ][ '@attributes' ][ 'name' ] = $eplug_userclass ;
2010-06-23 10:21:21 +00:00
$ret [ 'userClasses' ][ 'class' ][ 0 ][ '@attributes' ][ 'description' ] = $eplug_userclass_description ;
2009-10-22 04:14:45 +00:00
}
2017-01-26 15:37:42 -08:00
$ret [ 'files' ] = preg_grep ( '/^([^.])/' , scandir ( e_PLUGIN . $plugName , SCANDIR_SORT_ASCENDING ));
2008-01-26 04:47:27 +00:00
// Set this key so we know the vars came from a plugin.php file
2011-08-17 00:49:39 +00:00
// $ret['plugin_php'] = true; // Should no longer be needed.
2008-01-27 01:34:59 +00:00
$this -> plug_vars = $ret ;
2009-12-09 22:38:18 +00:00
2017-01-26 15:37:42 -08:00
2008-01-27 01:34:59 +00:00
return true ;
2008-01-26 04:47:27 +00:00
}
2008-08-09 16:49:58 +00:00
// Called to parse the plugin.xml file if it exists
2018-08-05 15:08:54 -07:00
/**
* @ deprecated To eventually be replaced by e_plugin :: parse_plugin_xml .
* @ param $plugName
* @ param null $where
* @ return bool
*/
2012-11-06 11:07:47 +00:00
function parse_plugin_xml ( $plugName , $where = null )
2008-01-26 04:47:27 +00:00
{
2009-12-09 22:38:18 +00:00
2009-09-03 22:27:32 +00:00
$tp = e107 :: getParser ();
2010-06-23 10:21:21 +00:00
// loadLanFiles($plugName, 'admin'); // Look for LAN files on default paths
2009-11-05 09:15:19 +00:00
$xml = e107 :: getXml ();
2012-08-22 02:45:32 +00:00
$mes = e107 :: getMessage ();
2017-02-03 20:18:45 -08:00
2017-12-02 11:57:27 -08:00
if ( E107_DEBUG_LEVEL > 0 )
{
2017-12-16 12:25:18 -08:00
$dbgArr = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 3 );
unset ( $dbgArr [ 0 ]);
e107 :: getDebug () -> log ( " Legacy Plugin Parse (xml): " . $plugName . print_a ( $dbgArr , true ));
2017-12-02 11:57:27 -08:00
}
2017-02-06 08:47:39 -08:00
2018-08-05 15:08:54 -07:00
2010-06-23 10:21:21 +00:00
// $xml->setOptArrayTags('extendedField,userclass,menuLink,commentID'); // always arrays for these tags.
// $xml->setOptStringTags('install,uninstall,upgrade');
2012-11-06 11:07:47 +00:00
if ( null === $where ) $where = 'plugin.xml' ;
2009-10-22 04:14:45 +00:00
2012-11-06 11:07:47 +00:00
$this -> plug_vars = $xml -> loadXMLfile ( e_PLUGIN . $plugName . '/' . $where , 'advanced' );
2012-08-22 02:45:32 +00:00
2008-12-10 13:27:09 +00:00
if ( $this -> plug_vars === FALSE )
2008-12-05 19:56:51 +00:00
{
2013-02-27 15:18:48 +01:00
$mes -> addError ( " Error reading { $plugName } /plugin.xml " );
2010-06-23 10:21:21 +00:00
return FALSE ;
2017-02-03 20:18:45 -08:00
}
2009-12-09 22:38:18 +00:00
$this -> plug_vars [ 'folder' ] = $plugName ; // remove the need for <folder> tag in plugin.xml.
2017-01-26 15:37:42 -08:00
$this -> plug_vars [ 'category' ] = ( isset ( $this -> plug_vars [ 'category' ])) ? $this -> manage_category ( $this -> plug_vars [ 'category' ]) : " misc " ;
$this -> plug_vars [ 'files' ] = preg_grep ( '/^([^.])/' , scandir ( e_PLUGIN . $plugName , SCANDIR_SORT_ASCENDING ));
2009-12-09 22:38:18 +00:00
2013-06-02 22:39:31 +01:00
if ( varset ( $this -> plug_vars [ 'description' ]))
2012-08-22 02:45:32 +00:00
{
2013-06-02 22:39:31 +01:00
if ( is_array ( $this -> plug_vars [ 'description' ]))
{
if ( isset ( $this -> plug_vars [ 'description' ][ '@attributes' ][ 'lan' ]) && defined ( $this -> plug_vars [ 'description' ][ '@attributes' ][ 'lan' ]))
{
// Pick up the language-specific description if it exists.
$this -> plug_vars [ 'description' ][ '@value' ] = constant ( $this -> plug_vars [ 'description' ][ '@attributes' ][ 'lan' ]);
2017-02-03 20:18:45 -08:00
}
2013-06-02 22:39:31 +01:00
}
else
{
$diz = $this -> plug_vars [ 'description' ];
unset ( $this -> plug_vars [ 'description' ]);
$this -> plug_vars [ 'description' ][ '@value' ] = $diz ;
}
2012-08-22 02:45:32 +00:00
}
2013-06-02 22:39:31 +01:00
2010-06-23 10:21:21 +00:00
// Very useful debug code.to compare plugin.php vs plugin.xml
2012-08-22 02:45:32 +00:00
/*
2010-06-23 10:21:21 +00:00
$testplug = 'forum' ;
if ( $plugName == $testplug )
{
$plug_vars1 = $this -> plug_vars ;
$this -> parse_plugin_php ( $testplug );
$plug_vars2 = $this -> plug_vars ;
ksort ( $plug_vars2 );
ksort ( $plug_vars1 );
echo " <table>
< tr >< td >< h1 > PHP </ h1 ></ td >< td >< h1 > XML </ h1 ></ td ></ tr >
< tr >< td style = 'border-right:1px solid black' > " ;
print_a ( $plug_vars2 );
echo " </td><td> " ;
print_a ( $plug_vars1 );
echo " </table> " ;
}
2012-08-22 02:45:32 +00:00
*/
2009-12-09 22:38:18 +00:00
// TODO search for $this->plug_vars['adminLinks']['link'][0]['@attributes']['primary']==true.
2009-09-23 23:18:18 +00:00
$this -> plug_vars [ 'administration' ][ 'icon' ] = varset ( $this -> plug_vars [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'icon' ]);
$this -> plug_vars [ 'administration' ][ 'caption' ] = varset ( $this -> plug_vars [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'description' ]);
$this -> plug_vars [ 'administration' ][ 'iconSmall' ] = varset ( $this -> plug_vars [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'iconSmall' ]);
$this -> plug_vars [ 'administration' ][ 'configFile' ] = varset ( $this -> plug_vars [ 'adminLinks' ][ 'link' ][ 0 ][ '@attributes' ][ 'url' ]);
2009-12-09 22:38:18 +00:00
2009-09-14 11:27:45 +00:00
return TRUE ;
}
2013-02-27 15:18:48 +01:00
}
2019-03-04 12:41:10 -08:00