--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Development
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_management_videos
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the contoller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ($actionData = false)
+ {
+
+ $resultMessage = '';
+ $success = false;
+ $haveMembers = false;
+ $import = false;
+ $importNotice = '';
+ $haveDatabaseTableList = false;
+ $databaseList = false;
+
+ // Get current database version
+ $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+ settype($dbVersion, 'string');
+
+ // Load database activation class to get access to database version information
+ require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php');
+ $activate = new glmMembersPluginActivate($this->wpdb, $this->config, true);
+
+ $option = '';
+ if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
+ $option = $_REQUEST['option'];
+ }
+
+ switch($option) {
+ case 'transfer_videos':
+ $resultMessage = '<pre>$_REQUEST: ' . print_r($_REQUEST, true) . '</pre>';
+ $sql = "
+ SELECT id,descr,video_url
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+ WHERE descr like '%youtube.com/embed%'
+ ORDER BY id";
+ $results = $this->wpdb->get_results( $sql, ARRAY_A );
+ //echo '<pre>$results: ' . print_r($results, true) . '</pre>';
+ if ( $results ) {
+ foreach ( $results as $member ) {
+ // parse out the iframe code
+ $descr = $member['descr'];
+ //$resultMessage .= '<pre>' . htmlspecialchars( $descr ) . '</pre>';
+ if ( preg_match( '%<iframe ?(.*)>(.*)</iframe>%', $descr, $matches ) ) {
+ // match 0 is the whole iframe
+ $iframeCode = $matches[0];
+ // from the first matched element get the src attribute
+ if ( preg_match( '%youtube.com/embed/([^?"]*)%', $matches[1], $srcMatches ) ) {
+ echo '<pre>$srcMatches: ' . print_r($srcMatches, true) . '</pre>';
+ }
+ //$resultMessage .= '<pre>$matches: ' . print_r($matches, true) . '</pre>';
+ }
+ }
+ }
+ break;
+
+ default:
+ // do a search for members with video embed code in descr field.
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info
+ WHERE descr like '%youtube.com/embed%'
+ ORDER BY id";
+ $count = $this->wpdb->get_var( $sql );
+ //echo '<pre>$count: ' . print_r($count, true) . '</pre>';
+ $resultMessage = "There are {$count} Members with embed code in their descr field.";
+ break;
+ }
+
+ $templateData['resultMessage'] = $resultMessage;
+ $templateData['success'] = $success;
+ $templateData['haveMembers'] = $haveMembers;
+ $templateData['importNotice'] = $importNotice;
+ $templateData['haveDatabaseTableList'] = $haveDatabaseTableList;
+ $templateData['databaseList'] = $databaseList;
+
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => true,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/management/videos.html',
+ 'data' => $templateData
+ );
+
+ }
+
+}