--- /dev/null
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Events
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package GLM Member-DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataFeedImport class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ * Exp $
+ */
+class GlmDataFeedImport extends GlmDataAbstract
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Data Table Name
+ *
+ * @var $table
+ * @access public
+ */
+ public $table;
+ /**
+ * Field definitions
+ *
+ * 'type' is type of field as defined by the application
+ * text Regular text field
+ * pointer Pointer to an entry in another table
+ * 'filters' is the filter name for a particular filter ID in PHP filter
+ * functions
+ * See PHP filter_id()
+ *
+ * 'use' is when to use the field
+ * l = List
+ * g = Get
+ * n = New
+ * i = Insert
+ * e = Edit
+ * u = Update
+ * d = Delete
+ * a = All
+ *
+ * @var $ini
+ * @access public
+ */
+ public $fields = false;
+ /**
+ * MemberInfo DB object
+ *
+ * @var $MemberInfo
+ * @access public
+ */
+ public $MemberInfo;
+
+ /**
+ * Constructor
+ *
+ * @param object $d database connection
+ * @param array $config Configuration array
+ * @param bool $limitedEdit Flag to say indicate limited edit requested
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct($wpdb, $config, $limitedEdit = false)
+ {
+
+ // If this class is not being extended along with existing $wpdb and $config
+ if (!$this->wpdb) {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Table Name
+ */
+ $this->table = GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'feed_import';
+
+ /*
+ * Table Data Fields
+ */
+
+ $this->fields = array (
+
+ 'id' => array (
+ 'field' => 'id',
+ 'type' => 'integer',
+ 'view_only' => true,
+ 'use' => 'a'
+ ),
+
+ // Feed URL
+ 'feed_url' => array (
+ 'field' => 'feed_url',
+ 'type' => 'text',
+ 'use' => 'a'
+ ),
+
+ // Created Date
+ 'name' => array (
+ 'field' => 'created',
+ 'type' => 'text',
+ 'use' => 'a'
+ ),
+
+ // Updated Date
+ 'phone' => array (
+ 'field' => 'updated',
+ 'type' => 'text',
+ 'use' => 'a'
+ ),
+
+ );
+
+ }
+
+ /*
+ * Entry Post Processing Call-Back Method
+ *
+ * Perform post-processing for all result entries.
+ *
+ * In this case we're using it to append an array of category
+ * data to each member result and also sort by member name.
+ *
+ * @param array $r Array of field result data for a single entry
+ * @param string $a Action being performed (l, i, g, ...)
+ *
+ * @return object Class object
+ *
+ */
+ public function entryPostProcessing($r, $a)
+ {
+ return $r;
+ }
+
+}
+
+?>
require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataManagement.php';
require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php');
require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php');
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataFeedImport.php');
/**
* GlmMembersAdmin_management_events
public function modelAction($actionData = false)
{
- $option = false;
- $test_result = false;
+ $option = false;
+ $test_result = false;
$import_result = false;
- $settings_updated = false;
+ $settings_updated = false;
$settings_update_error = false;
- $event_settings = false;
+ $event_settings = false;
+ $icalFeedResult = false;
+ $import_feeds = false;
+ $option2 = false;
if (isset($_REQUEST['option'])) {
$option = $_REQUEST['option'];
}
+ $importFeeds = new GlmDataFeedImport( $this->wpdb, $this->config );
+
switch ($option) {
+
case 'timelyImport':
$import = false;
if (isset($_REQUEST['import'])) {
$import_result = $this->importFromTimely();
break;
- case 'tests':
-
- $test = false;
- if (isset($_REQUEST['test'])) {
- $test = $_REQUEST['test'];
+ case 'icalfeed':
+ if ( isset( $_REQUEST['option2'] ) ) {
+ $option2 = filter_var( $_REQUEST['option2'], FILTER_SANITIZE_STRING );
}
-
- switch ($test) {
-
- case 'recurrence':
-
- $test_result = $this->testRecurrence();
-
- break;
-
- default:
- break;
+ $icalFeedResult = '';
+ if ( $option2 === 'delete' && $feed_id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+ $this->wpdb->delete(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "feed_import",
+ array( 'id' => $feed_id ),
+ '%d'
+ );
+ }
+ if ( $feed_url = filter_var( $_REQUEST['feed_url'], FILTER_VALIDATE_URL ) ) {
+ // Add this feed url to the table
+ $this->wpdb->insert(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "feed_import",
+ array(
+ 'feed_url' => $feed_url,
+ 'created' => current_time( 'mysql' )
+ ),
+ '%s'
+ );
}
break;
}
+ $import_feeds = $importFeeds->getList();
+
// Compile template data
$template_data = array(
+ 'import_feeds' => $import_feeds,
'option' => $option,
'testResult' => $test_result,
'importResult' => $import_result,
'settingsUpdated' => $settings_updated,
'settingsUpdateError' => $settings_update_error,
- 'eventsSettings' => $event_settings
+ 'eventsSettings' => $event_settings,
+ 'icalFeedResult' => $icalFeedResult,
);
// Return status, suggested view, and data to controller
}
}
- /**
- * Test Recurrance Calculation of Dates
- *
- * @return test Text of test results
- */
- public function testRecurrence()
- {
-
- $res = '';
-
- // Load recurrences class
- require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php';
- $Recurrences = new GlmDataEventsRecurrences($this->wpdb, $this->config);
-
- // Create sample recurrence entry
- $start_time = '2016/2/27 08:00:00';
- $res .= "First event start date/time: $start_time<br>";
- $end_time = '2016/2/28 17:00:00';
- $res .= "First event end date/time: $end_time<br>";
- $from_date = '2016/2/1';
- $res .= "From date: $from_date<br>";
- $to_date = '2017/3/31';
- $res .= "To date: $to_date<br>";
-
- $this->wpdb->insert(
- GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences',
- array(
- 'event' => 999999999,
- 'start_time' => $start_time,
- 'end_time' => $end_time,
- 'from_date' => $from_date,
- 'to_date' => $to_date,
- 'all_day' => false,
- 'month_of_year' =>
- pow(2, $this->config['month_bit']['January']) +
- pow(2, $this->config['month_bit']['June']),
- 'week_of_month' =>
- pow(2, $this->config['week_bit']['Third']) +
- pow(2, $this->config['week_bit']['First']),
- 'day_of_week' =>
- pow(2, $this->config['day_bit']['Wednesday']) +
- pow(2, $this->config['day_bit']['Friday']),
- 'day_of_month' =>
- pow(2, 1) + pow(2, 13) + pow(2, 26) + pow(2, 30),
- 'last_day_of_month' => true,
- 'holiday' => 0,
- 'holiday_offset' => 0
- ),
- array(
- '%d',
- '%s',
- '%s',
- '%s',
- '%s',
- '%d',
- '%d',
- '%d',
- '%d',
- '%d',
- '%d',
- '%d',
- '%d'
- )
- );
- $recurID = $this->wpdb->insert_id;
- if (!$recurID) {
- return 'Error inserting recurrence entry!';
- }
-
- // Run recurrence time function
- $Recurrences->optionIncludeSelectListData = false;
- $times = $Recurrences->createRecurrenceTimesEntries($recurID, true, true);
-
- // Delete test recurrence
- $this->wpdb->delete( GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'recurrences', array( 'ID' => $recurID ) );
- $this->wpdb->delete( GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'times', array( 'recur_id' => $recurID ) );
-
- $res .= "<h3>Times Entries Generated</h3><pre>".print_r($times,1)."</pre>";
-
- return $res;
-
- }
-
/**
* addCategories
*
<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
<a id="glm-settings" data-show-table="glm-table-settings" class="glm-settings-tab nav-tab{if $option=='settings'} nav-tab-active{/if}">Settings</a>
- <a id="glm-tests" data-show-table="glm-table-tests" class="glm-settings-tab nav-tab{if $option=='tests'} nav-tab-active{/if}">Tests</a>
+ <a id="glm-icalfeed" data-show-table="glm-table-icalfeed" class="glm-settings-tab nav-tab{if $option=='icalfeed'} nav-tab-active{/if}">iCal Feed</a>
<a id="glm-eventimport" data-show-table="glm-table-eventimport" class="glm-settings-tab nav-tab{if $option=='eventimport'} nav-tab-active{/if}">Import</a>
<a id="glm-timelyimport" data-show-table="glm-table-timelyimport" class="glm-settings-tab nav-tab{if $option=='timelyimport'} nav-tab-active{/if}">Timely Import</a>
</h2>
<!-- Tests -->
- <table id="glm-table-tests" class="glm-admin-table glm-settings-table{if $option!='tests'} glm-hidden{/if}">
- {if $testResult}
- <tr><td><a href="{$thisUrl}?page={$thisPage}&glm_action=events&option=tests">Return to Test List</a></td></tr>
+ <table id="glm-table-icalfeed" class="glm-admin-table glm-settings-table{if $option!='icalfeed'} glm-hidden{/if}">
+ {if $icalFeedResult}
<tr>
<td colspan="2">
- {$testResult}
+ {$icalFeedResult}
</td>
</tr>
- {else}
+ {/if}
<tr>
<td colspan="2">
- <ul>
- <li><a href="{$thisUrl}?page={$thisPage}&glm_action=events&option=tests&test=recurrence">Recurrence Times Generation Test</a></li>
- </ul>
+ <form action="{$thisUrl}">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="glm_action" value="events" />
+ <input type="hidden" name="option" value="icalfeed" />
+ <label for="glm_event_feed_url">Feed Url for Import</label><br />
+ <input type="text" id="glm_event_feed_url" name="feed_url" value="" />
+ <input class="button" type="submit" value="Add Feed Url" />
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <table >
+ <tr>
+ <th> </th>
+ <th>Feed Url</th>
+ <th>Created Date</th>
+ <th>Updated Date</th>
+ <th> </th>
+ </tr>
+ {foreach $import_feeds as $feed}
+ <tr>
+ <td><a href="#" class="button">Refresh</a></td>
+ <td>{$feed.feed_url}</td>
+ <td>{$feed.created}</td>
+ <td>{$feed.updated}</td>
+ <td><a href="{$thisUrl}?page={$thisPage}&glm_action=events&option=icalfeed&option2=delete&id={$feed.id}"
+ onClick="return confirm('This cannot be undone!\nAre you sure?')" class="button">Delete</a></td>
+ </tr>
+ {/foreach}
+ </table>
</td>
</tr>
- {/if}
</table>
<!-- Import -->