<?php
+use net\authorize\api\contract\v1\ProcessorType;
+use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
+
/**
* Gaslight Media Members Database
* Plugin support class
* Stand alone functions that are needed globally for these plugins/add-ons
*/
-/*
- * Function to display admin notices.
+/**
+ * Function to build a more useable array from a config table
*
- * This function is only called using the add_action('admin_notices','...') function
- * in the code below this function.
+ * @param $configTable array Copy of config table as an array (from $config) to process indexed by numbers - Required
+ * @param $configNubTable array Copy of matching table indexed by names - Optional
+ * @param $configSelected array Simple array of numberic IDs of entries that should be selected (true) by default - Optional
*
- * @return void
- * @access public
+ * @return array Array of config table entries
+ *
+ * array(
+ * index => array(
+ * 'id' => Index number for this entry (key from config array)
+ * 'descr' => Text description of entry,
+ * 'name' => Name of field used to find ID (key from names array)
+ * 'selected' => Selected flag, all initialized to false
+ * )
+ * )
*/
-function glmMembersAdminNotices($windowed = true)
+function glmMembersConfigArraySetup( $configTable, $configNumbTable = false, $configSelectedArray)
{
- // Depreciating debug system
- return;
-/*
- $output = '';
-
- // If windowed for debug, also include HTML header and stylesheet
- if ($windowed) {
-
- $output .= '
- <html>
- <head>
- <link rel="stylesheet" href="'.GLM_MEMBERS_PLUGIN_URL.'/css/admin.css">
- <head>
- <body>
- <a name="top"></a>
- <div id="glm-debug-timestamp">'.date('m/d/Y G:i:s A').'</div>
- <div id="glm-debug-header">'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data</div>
- ';
-
- // Display alerts
- $alerts = get_option('glmMembersAdminNoticeAlerts');
- if(is_array($alerts)) {
- $output .= '<div id="glm-debug-alerts" class="glm-error"><h2>Alerts</h2>';
- foreach($alerts as $a) {
- $output .= $a.'<br>';
- }
- } else {
- $output .= '<div id="glm-debug-alerts"><h2>Alerts</h2>';
- }
- $output .= '</div><hr>';
- delete_option('glmMembersAdminNoticeAlerts');
-
- // Display process messages
- $process = get_option('glmMembersAdminNoticeProcess');
- $output .= '<div id="glm-debug-process"><h2>Processing</h2>';
- if(is_array($process)) {
- foreach($process as $p) {
- $output .= $p.'<br>';
- }
- }
- $output .= '</div><hr>';
- delete_option('glmMembersAdminNoticeProcess');
-
- // Display data blocks table of contents then the data blocks
- $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks');
- $output .= '<div id="glm-debug-contents"><h2>Data Blocks</h2><ul>';
- $n = 0;
- if (is_array($dataBlocks)) {
- foreach($dataBlocks as $d) {
- $output .= '<li><a href="#'.++$n.'">'.$d['title'].'</a></li>';
+
+ // Check if config table array exits
+ if (!is_array($configTable) || count($configTable) == 0) {
+ return false;
+ }
+
+ // Build base array
+ $conf = array();
+ foreach ($configTable as $key=>$descr) {
+ $conf[$key] = array(
+ 'id' => $key,
+ 'descr' => $descr,
+ 'name' => false,
+ 'selected' => false
+ );
+ }
+
+ // If name->number array add that data
+ if (is_array($configNumbTable) && count($configNumbTable) > 0) {
+ foreach ($configNumbTable as $name=>$key) {
+ if (isset($conf[$key])) {
+ $conf[$key]['name'] = $name;
}
}
+ }
- $output .= '</ul></div><hr>';
- if (is_array($dataBlocks)) {
- reset($dataBlocks);
- $n = 0;
- foreach($dataBlocks as $d) {
- $output .= '
- <div style="margin-top: 2em;">
- <div style="float: right;"><a href="#top">[Top]</a></div>
- <div class="glm-debug-section-title"><a name="'.++$n.'"><h4>'.$d['title'].'</h4></a></div>
- <div class="glm-debug-section-body"><pre>'.print_r($d['data'],1).'</pre></div>
- </div>
- ';
+ // If a selected array is provided, add that data
+ if (is_array($configSelectedArray) && count($configSelectedArray) > 0) {
+ foreach ($configSelectedArray as $key) {
+ if (isset($conf[$key])) {
+ $conf[$key]['selected'] = true;
}
}
+ }
- echo $output.'
- </body>
- </html>
- ';
-
- // Otherwise we're outputting data to the message block in the WordPress admin area
- } else {
-
- // Start with div class to output in standard admin notice block
- $output .= '<div class="updated"><p>';
-
- // Get the notice texts
- $notices = get_option('glmMembersAdminNotices');
-
- if (is_array($notices) && count($notices) > 0) {
-
- // For each notice retrieved
- $br = '';
- foreach($notices as $n) {
-
- // Add the notice to the output
- $output .= $br.$n;
- $br = '<br>';
- }
+ return $conf;
- }
+}
- echo $output.'</p></div>';
+/**
+ * Function to display admin notices. - Depreciated
+ *
+ * This function is only called using the add_action('admin_notices','...') function
+ * in the code below this function.
+ *
+ * @return void
+ * @access public
+ */
+function glmMembersAdminNotices($windowed = true)
+{
- }
+ // Depreciating original debug system
+ return;
- delete_option('glmMembersAdminNoticeAlerts');
- delete_option('glmMembersAdminNotices');
- delete_option('glmMembersAdminNoticeProcess');
- delete_option('glmMembersAdminNoticeDataBlocks');
-*/
}
/**
public function glmMembersAdminAjax()
{
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ trigger_error(glmAssociateMemoryUsage()." - Start AJAX Controller",E_USER_NOTICE);
+ trigger_error(glmAssociateTimeTracker()." - Start AJAX Controller",E_USER_NOTICE);
+ }
+
$defaultTimeZone = date_default_timezone_get();
date_default_timezone_set($this->config['settings']['time_zone']);
}
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ trigger_error("AJAX Controller, Model = $modelName",E_USER_NOTICE);
+ trigger_error("AJAX Controller, View = $viewPath/$viewFile",E_USER_NOTICE);
+ }
+
/*
* Merge data returned from the model with the selected view
*/
// Restore timezone that was set before our code was called
date_default_timezone_set($defaultTimeZone);
+ if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+ trigger_error(glmAssociateMemoryUsage()." - End AJAX Controller",E_USER_NOTICE);
+ trigger_error(glmAssociateTimeTracker()." - End AJAX Controller",E_USER_NOTICE);
+ }
+
exit; // Need to test if this is here for a reason!
wp_die();