Working on adding site plugin records.
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @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;
+ }
+}
)
);
$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;
$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';
$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,
{* Form End *}
{include file='ui/f6/form-end.html'}
+
<style>
.row-green {
background-color: rgb( 225, 250, 234 );
{$baseUrl = "{$thisUrl}?page={$thisPage}&glm_action={$thisAction}&option=view&plugin_id={$plugin.fieldData.id}"}
{$SitePluginUrl = "{$thisUrl}?page={$thisPage}&glm_action={$thisAction}plugin_id={$plugin.fieldData.id}"}
+<a class="button primary" href="{$baseUrl}&option=pluginSite{if !empty($smarty.request.order)}&order={$smarty.request.order}{/if}">Add Site</a>
+
{if !empty($sites)}
<table class="stack hover">
<tr>
{* Header *}
{include file="admin/header.html"}
-<h3> {$sitePlugin.fieldData.site.name} - {$sitePlugin.fieldData.plugin.name} </h3>
+{if $newEntry}
+ <h3> New Site - {$pluginName} </h3>
+{else}
+ <h3> {$sitePlugin.fieldData.site.name} - {$sitePlugin.fieldData.plugin.name} </h3>
+{/if}
{* Grid Start *}
{$ui = [
{$data = $sitePlugin}
<input type="hidden" name="glm_action" value="plugins">
- <input type="hidden" name="option" value="savePluginSite">
- <input type="hidden" name="id" value="{$data.fieldData.id}">
- <input type="hidden" name="plugin_id" value="{$data.fieldData.plugin.value}">
- <input type="hidden" name="plugin" value="{$data.fieldData.plugin.value}">
- <input type="hidden" name="site" value="{$data.fieldData.site.value}">
+ {if $newEntry}
+ <input type="hidden" name="option" value="addPluginSite">
+ <input type="hidden" name="plugin_id" value="{$smarty.request.plugin_id}">
+ <input type="hidden" name="plugin" value="{$smarty.request.plugin_id}">
+
+ {* Site *}
+ {$ui = [
+ 'value' => $data.fieldData.site.value,
+ 'field' => 'site',
+ 'label' => 'Site',
+ 'list' => $data.fieldData.site.list,
+ 'l_label' => 'name',
+ 'l_value' => 'value',
+ 'l_blank' => false,
+ 'required' => $data.fieldRequired.site,
+ 'errorText' => 'Site is Required',
+ 'dataError' => $data.fieldFail.site
+ ]}
+ {include file='ui/f6/select.html'}
+
+ {else}
+ <input type="hidden" name="option" value="savePluginSite">
+ <input type="hidden" name="id" value="{$data.fieldData.id}">
+ <input type="hidden" name="plugin_id" value="{$data.fieldData.plugin.value}">
+ <input type="hidden" name="plugin" value="{$data.fieldData.plugin.value}">
+ <input type="hidden" name="site" value="{$data.fieldData.site.value}">
+ {/if}
{if !empty($smarty.request.order)}
<input type="hidden" name="order" value="{$smarty.request.order}">
{/if}