From: Steve Sutton Date: Wed, 9 Oct 2019 20:55:47 +0000 (-0400) Subject: Adding more functianality to site plugins. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=cfb696e46b807f704c8bf7d1dec580e8df8597a8;p=WP-Plugins%2Fglm-member-db-plugins.git Adding more functianality to site plugins. Working on adding site plugin records. --- diff --git a/models/admin/ajax/pluginListSites.php b/models/admin/ajax/pluginListSites.php new file mode 100644 index 0000000..23b6a45 --- /dev/null +++ b/models/admin/ajax/pluginListSites.php @@ -0,0 +1,99 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +require_once GLM_MEMBERS_PLUGINS_PLUGIN_CLASS_PATH.'/data/dataSites.php'; +/** + * Steve Note + * + * You can get to this using the following URL. + * + * + {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue + * + * You should be able to do this as POST or GET and should be able to add and read additional parameters. + * I added a "mystuff" parameter to the URL above and it does output from the code in the + * modelAction() function below. + * + * To add another model under models/admin/ajax all you need to do is create it and add it to the + * setup/validActions.php file. + * + */ + +// Load Members data abstract +// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php'; + +/** + * This class performs the work of handling images passed to it via + * an AJAX call that goes through the WorPress AJAX Handler. + * + */ +class GlmMembersAdmin_ajax_pluginListSites extends GlmDataSites +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct( false, false ); + + } + + public function modelAction( $actionData = false ) { + + // $where = "T.prod_server = 2"; // norax + $where = "T.prod_server = 1"; // eleusis + $where .= " + AND T.id IN (SELECT site + FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins + WHERE plugin = 7) + "; + + $config = array( + 'order' => 'name', + 'where' => $where, + ); + + $sites = $this->getResults( $config ); + + $siteOut = array(); + foreach ( $sites as $site ) { + $siteOut[] = $site['prod_url']; + } + echo implode( "\n", $siteOut ); + + exit; + } +} diff --git a/models/admin/plugins/plugins.php b/models/admin/plugins/plugins.php index f8c39f2..232ab75 100644 --- a/models/admin/plugins/plugins.php +++ b/models/admin/plugins/plugins.php @@ -142,6 +142,12 @@ class GlmMembersAdmin_plugins_plugins extends GlmDataPlugins ) ); $tData['sitePlugin'] = $SitePlugins->editEntry( $sitePluginId ); + $tData['newEntry'] = false; + } else { + // Get plugin name. + $tData['pluginName'] = $this->wpdb->get_var( "SELECT name FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "plugins WHERE id = $id" ); + $tData['sitePlugin'] = $SitePlugins->newEntry(); + $tData['newEntry'] = true; } } break; @@ -157,6 +163,12 @@ class GlmMembersAdmin_plugins_plugins extends GlmDataPlugins $sitePlugin = $SitePlugins->updateEntry( $id ); } + case 'addPluginSite': + $SitePlugins = new GlmDataSitePlugin( $this->wpdb, $this->config ); + if ( !isset( $_REQUEST['id'] ) ) { + $sitePlugin = $SitePlugins->insertEntry(); + } + case 'view': $view = 'plugin-detail'; $orderBy = 'S.name'; diff --git a/setup/validActions.php b/setup/validActions.php index f08a238..7798060 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -59,6 +59,9 @@ $glmMemberPluginsAddOnValidActions = array( 'adminActions' => array( + 'ajax' => array( + 'pluginListSites' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG, + ), 'plugins' => array( 'index' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG, 'plugins' => GLM_MEMBERS_PLUGINS_PLUGIN_SLUG, diff --git a/views/admin/plugins/plugin-detail.html b/views/admin/plugins/plugin-detail.html index e31ad5d..79031ce 100644 --- a/views/admin/plugins/plugin-detail.html +++ b/views/admin/plugins/plugin-detail.html @@ -89,6 +89,7 @@ {* Form End *} {include file='ui/f6/form-end.html'} +