From 72eaff6d8bdc63013f58f269d9ea3f6eb01f7385 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 10 Mar 2016 15:00:59 -0500 Subject: [PATCH] Utilizing the data abstract --- .../data/{dataSocial.php => dataRecords.php} | 43 ++- classes/data/dataUrls.php | 258 +++++++++++++++ models/admin/info/index.php | 125 -------- models/admin/member/social.php | 166 ++++------ models/admin/settings/social.php | 74 ++--- models/admin/social/index.php | 298 ------------------ models/admin/social/more.php | 148 --------- setup/adminMenus.php | 54 ++-- .../create_database_V0.0.1.sql | 28 +- setup/validActions.php | 7 - views/admin/info/index.html | 6 - views/admin/member/social.html | 24 +- views/admin/settings/social.html | 14 +- views/admin/social/index.html | 28 -- views/admin/social/more.html | 6 - 15 files changed, 449 insertions(+), 830 deletions(-) rename classes/data/{dataSocial.php => dataRecords.php} (77%) create mode 100644 classes/data/dataUrls.php delete mode 100644 models/admin/info/index.php delete mode 100644 models/admin/social/index.php delete mode 100644 models/admin/social/more.php delete mode 100644 views/admin/info/index.html delete mode 100644 views/admin/social/index.html delete mode 100644 views/admin/social/more.html diff --git a/classes/data/dataSocial.php b/classes/data/dataRecords.php similarity index 77% rename from classes/data/dataSocial.php rename to classes/data/dataRecords.php index 4f1b998..1ac163d 100644 --- a/classes/data/dataSocial.php +++ b/classes/data/dataRecords.php @@ -27,7 +27,7 @@ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); /** - * GlmDataSocial class + * GlmDataRecords class * * PHP version 5 * @@ -38,7 +38,7 @@ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ */ -class GlmDataSocial extends GlmDataAbstract +class GlmDataRecords extends GlmDataAbstract { /** @@ -121,7 +121,7 @@ class GlmDataSocial extends GlmDataAbstract /* * Table Name */ - $this->table = GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socialtable'; + $this->table = GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'records'; /* * Table Data Fields @@ -129,6 +129,7 @@ class GlmDataSocial extends GlmDataAbstract $this->fields = array ( + // Social ID 'id' => array ( 'field' => 'id', 'type' => 'integer', @@ -136,6 +137,38 @@ class GlmDataSocial extends GlmDataAbstract 'use' => 'a' ), + // Name of the social record + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // X Position of icon in sprite + 'xpos' => array ( + 'field' => 'xpos', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Y Position of icon in sprite + 'ypos' => array( + 'field' => 'ypos', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Base url of the social record + 'baseurl' => array( + 'field' => 'baseurl', + 'type' => 'text', + 'required' => true, + 'use' => 'a' + ), + // Active flag 'active' => array ( 'field' => 'active', @@ -143,9 +176,7 @@ class GlmDataSocial extends GlmDataAbstract 'default' => true, 'use' => 'a' ) - - ); - + ); } /* diff --git a/classes/data/dataUrls.php b/classes/data/dataUrls.php new file mode 100644 index 0000000..f0e16db --- /dev/null +++ b/classes/data/dataUrls.php @@ -0,0 +1,258 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/********************************************************************** + * NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED + * + * Please change all references to social, Social, or SOCIAL to a name + * appropriate for your new Add-On. + * + * Data fields in this file are social only. + * + * Remove this message before using this file in production! + **********************************************************************/ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataUrls class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Gaslight Media + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataUrls 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_SOCIAL_PLUGIN_DB_PREFIX . 'urls'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + // Social ID + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // The member's URL for facebook + 'facebook' => array ( + 'field' => 'facebook', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + // The member's URL for twitter + 'twitter' => array ( + 'field' => 'twitter', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for pinterest + 'pinterest' => array ( + 'field' => 'pinterest', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for googleplus + 'googleplus' => array ( + 'field' => 'googleplus', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for digg + 'digg' => array ( + 'field' => 'digg', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for linkedin + 'linkedin' => array ( + 'field' => 'linkedin', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for instagram + 'instagram' => array ( + 'field' => 'instagram', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for rss + 'rss' => array ( + 'field' => 'rss', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for youtube + 'youtube' => array ( + 'field' => 'youtube', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for flickr + 'flickr' => array ( + 'field' => 'flickr', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for blog + 'blog' => array ( + 'field' => 'blog', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + + // The member's URL for photobucket + 'photobucket' => array ( + 'field' => 'photobucket', + 'type' => 'text', + 'default' => true, + '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; + } + +} + +?> \ No newline at end of file diff --git a/models/admin/info/index.php b/models/admin/info/index.php deleted file mode 100644 index 2440b68..0000000 --- a/models/admin/info/index.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -// Load Contacts data abstract -//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); - -class GlmMembersAdmin_info_index // extends GlmDataContacts -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - /** - * Contact Info - * - * @var $contactInfo - * @access public - */ - public $contactInfo = false; - /** - * Member ID - * - * @var $memberID - * @access public - */ - public $memberID = false; - /** - * Contact ID - * - * @var $contactID - * @access public - */ - public $contactID = false; - - - /* - * Constructor - * - * This contructor performs the work for this model. This model returns - * an array containing the following. - * - * 'status' - * - * True if successfull and false if there was a fatal failure. - * - * '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. - * - * @wpdb object WordPress database object - * - * @return array Array containing status, suggested view, and any data - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - /* - * Run constructor for the Contacts data class - * - * Note, the third parameter is a flag that indicates to the Contacts - * data class that it should flag a group of fields as 'view_only'. - */ -// parent::__construct(false, false, true); - - - } - - public function modelAction($actionData = false) - { - - $displayData = 'This is the Social Add-On "Info" model talking to you from inside WordPress.'; - - // Compile template data - $templateData = array( - 'displayData' => $displayData - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/info/index.html', - 'data' => $templateData - ); - - } - - -} diff --git a/models/admin/member/social.php b/models/admin/member/social.php index e898656..20a3236 100644 --- a/models/admin/member/social.php +++ b/models/admin/member/social.php @@ -14,9 +14,9 @@ */ // Load Contacts data abstract -require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocial.php'); +require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataUrls.php'); -class GlmMembersAdmin_member_social extends GlmDataSocial +class GlmMembersAdmin_member_social extends GlmDataUrls { /** @@ -103,23 +103,23 @@ class GlmMembersAdmin_member_social extends GlmDataSocial - public function updateUrlList(&$existingUrls) { - $getExistingUrls = " - SELECT * - FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_urls - ;"; - $existingUrls = $this->wpdb->get_results($getExistingUrls, ARRAY_A); -// $existingUrls = $queryUrls[0]; - return; - } +// public function updateUrlList(&$existingUrls) { +// $getExistingUrls = " +// SELECT * +// FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."urls +// ;"; +// $existingUrls = $this->wpdb->get_results($getExistingUrls, ARRAY_A); +//// $existingUrls = $queryUrls[0]; +// return; +// } - public function printSocialList(&$array,$name="Array list") { - echo "
$name:"; - foreach($array[0] as $key=>$value) { - echo(""); - } - echo "
$key$value
"; - } +// public function printSocialList(&$array,$name="Array list") { +// echo "
$name:"; +// foreach($array[0] as $key=>$value) { +// echo(""); +// } +// echo "
$key$value
"; +// } public function modelAction($actionData = false) { @@ -129,40 +129,33 @@ class GlmMembersAdmin_member_social extends GlmDataSocial $socialUpdated = false; $haveMember = false; $socialError = false; - $newSocial = false; $option = false; $debug = true; - - // The above array needs to be inserted into the Database - $getExistingSocials = " - SELECT * - FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_record - ;"; - $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A); - $getExistingUrls = " - SELECT * - FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_urls - ;"; - $existingUrls = $this->wpdb->get_results($getExistingUrls, ARRAY_A); - // If there's an action option + $statusMessage = "debug mode"; + + $Urls = new GlmDataUrls($this->wpdb, $this->config); + $urlStats = $Urls->getStats(); + $haveUrls = ($urlStats > 0); + + if ($urlStats && $urlStats > 0) { + $haveUrls = true; + } + + $urlList = $Urls->getList(); + + require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataRecords.php'); + $Records = new GlmDataRecords($this->wpdb, $this->config); + if (isset($_REQUEST['option'])) { $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); } else { $option = "default"; } - - echo "
Request:"; - foreach($_REQUEST as $key=>$value) { - echo(""); - } - echo "
$key$value
"; -// $formUrls = array_filter($_REQUEST, function($k) { -// return preg_match('/^socialname-/',$k); -// }, ARRAY_FILTER_USE_KEY); - + $recordList = $Records->getList(); + // Get the Member ID - $memberID = 0; + $memberID = '0'; if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) { $memberID = $_REQUEST['member'] - 0; } @@ -175,70 +168,36 @@ class GlmMembersAdmin_member_social extends GlmDataSocial 'view' => 'admin/error/index.html', 'data' => false ); - } + echo "
Request:"; + foreach($_REQUEST as $key=>$value) { + echo(""); + } + echo "
$key$value
"; + echo "
UrlList:"; + echo "
".print_r($urlList[$memberID], true)."
"; + echo "
"; + + if (!$Urls->getEntry($memberID)){ + $sql = " + INSERT INTO ".$Urls->table." + (id) + VALUES ($memberID) + ;"; + $this->wpdb->query($sql); + echo "sql: $sql"; + } + switch ($option) { case "submit": - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("  Social Update: $memberID", 'Process'); - } + $Urls->updateEntry($memberID); + - // Refresh the list of URLs based on the Database values - $this->updateUrlList($existingUrls); - if ($debug) { - $this->printSocialList($existingUrls,"Existing Urls Pre Submit"); - } - $socialUpdated = false; - $statusMessage=""; - foreach($existingUrls[0] as $social=>$socialUrl) { - // Reset the query - $sql = ""; - - // Grab the URL for the current Social Media from the form - if (isset($_REQUEST['socialname-'.$social])) { - $formUrl = trim(filter_var($_REQUEST['socialname-'.$social],FILTER_SANITIZE_STRING)); - } else { - $formUrl = 1; - if ($debug) { - echo "
FAILED socialUrl REQUEST for ".$social."
"; - } - } - if ($socialUrl == 1 || $formUrl == $socialUrl || $formUrl == 1) { - // If it encounters the Member ID from the DB, the error code for the form, - // or the form does not differ from the database: skip this iteration - continue; - } else { - $sql = " - UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_urls - SET ".$social." = '".$formUrl."' - WHERE member_id = $memberID - ;"; - $statusMessage = "The selected social links have been updated."; - $socialUpdated = true; - $this->wpdb->query($sql); - } - if ($socialUpdated) { - echo "
".$statusMessage."
"; - if ($debug){ - echo "
Social:".$social."
"; - echo "
Social url:".$socialUrl."
"; - echo "
statement:".$sql."
"; - } - } - } - if ($debug) { - $this->updateUrlList($existingUrls); - $this->printSocialList($existingUrls,"Existing Urls Post Submit"); - } break; case "social"; default: - if ($debug) { - $this->updateUrlList($existingUrls); - $this->printSocialList($existingUrls,"Existing Urls Default:"); - } break; } @@ -254,23 +213,16 @@ class GlmMembersAdmin_member_social extends GlmDataSocial ); } - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); - } - // Refresh the URL list before sending it to the front - $this->updateUrlList($existingUrls); - // Compile template data $templateData = array( 'displayData' => $displayData, - 'existingSocials' => $existingSocials, + 'socials' => $recordList, + 'urlList' => $urlList[$memberID], 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, - 'socials' => $socials, 'socialUpdated' => $socialUpdated, 'socialError' => $socialError, 'haveMember' => $haveMember, 'memberID' => $memberID, 'option' => $option, - 'existingUrls' => $existingUrls[0], 'statusMessage' => $statusMessage ); diff --git a/models/admin/settings/social.php b/models/admin/settings/social.php index 1276e59..adb6a8a 100644 --- a/models/admin/settings/social.php +++ b/models/admin/settings/social.php @@ -71,59 +71,56 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts // Save plugin configuration object $this->config = $config; - /* - * Run constructor for the Contacts data class - * - * Note, the third parameter is a flag that indicates to the Contacts - * data class that it should flag a group of fields as 'view_only'. - */ -// parent::__construct(false, false, true); - - } - public function updateSocialList(&$existingSocials) { - $getExistingSocials = " - SELECT * - FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_record - ;"; - $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A); - } - - public function printSocialList($array,$name="Array list") { - echo "
$name"; - $i = 0; - foreach($array as $key=>$socialRecord) { - foreach($socialRecord as $recordKey=>$recordValue) - echo(""); - $i++; - } - echo "
$recordKey$recordValue

"; - } +// public function updateSocialList(&$existingSocials) { +// $getExistingSocials = " +// SELECT * +// FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records +// ;"; +// $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A); +// } +// +// public function printSocialList($array,$name="Array list") { +// echo "
$name"; +// $i = 0; +// foreach($array as $key=>$socialRecord) { +// foreach($socialRecord as $recordKey=>$recordValue) +// echo(""); +// $i++; +// } +// echo "
$recordKey$recordValue

"; +// } public function modelAction($actionData = false) { $displayData = 'Hello, World! This is the Social Add-On "settings" model talking to you from inside WordPress.'; $success = true; - $socials = false; $socialUpdated = false; $socialError = false; $option = false; $debug = true; $statusMessage = 'Social Updated'; - $getExistingSocials = " - SELECT * - FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_record - ;"; - $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A); +// $getExistingSocials = " +// SELECT * +// FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records +// ;"; +// $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A); // If there's an action option if (isset($_REQUEST['option'])) { $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); } else { $option = "default"; } + + $socials = new GlmDataSocial($this->wpdb, $this->config); + $socialInfo = $socials->getEntry(); + + + $urls = new GlmDataUrls($this->wpdb, $this->config); + $urlList = $urls->getEntry($memberID); echo "
Request:"; foreach($_REQUEST as $socialRecord=>$value) { @@ -142,19 +139,19 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts $sql = ""; $recordBool = $socialRecord['active']; - if(isset($_REQUEST['checkname-'.strtolower($socialRecord['social_name'])])){ + if(isset($_REQUEST['checkname-'.strtolower($socialRecord['name'])])){ $socialBool = 1; } else { $socialBool = 0; } -// echo " | checkname-".strtolower($socialRecord['social_name'])." | "; -// $socialChecked = $_REQUEST['checkname-'.strtolower($socialRecord['social_name'])]; +// echo " | checkname-".strtolower($socialRecord['name'])." | "; +// $socialChecked = $_REQUEST['checkname-'.strtolower($socialRecord['name'])]; if ($socialBool != $recordBool) { echo " - Unequal, rec:$recordBool and soc:$socialBool
"; $sql = " - UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_record + UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records SET active = $socialBool - WHERE social_id = ".$socialRecord['social_id']." + WHERE id = ".$socialRecord['id']." ;"; $socialUpdated = true; $this->wpdb->query($sql); @@ -204,7 +201,6 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts $templateData = array( 'displayData' => $displayData, 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, - 'socials' => $socials, 'socialUpdated' => $socialUpdated, 'socialError' => $socialError, 'option' => $option, diff --git a/models/admin/social/index.php b/models/admin/social/index.php deleted file mode 100644 index 6679d73..0000000 --- a/models/admin/social/index.php +++ /dev/null @@ -1,298 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -// Load Contacts data abstract -//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); - - - - -class GlmMembersAdmin_social_index // extends GlmDataContacts -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - /** - * Contact Info - * - * @var $contactInfo - * @access public - */ - public $contactInfo = false; - /** - * Member ID - * - * @var $memberID - * @access public - */ - public $memberID = false; - /** - * Contact ID - * - * @var $contactID - * @access public - */ - public $contactID = false; - - - /* - * Constructor - * - * This contructor performs the work for this model. This model returns - * an array containing the following. - * - * 'status' - * - * True if successfull and false if there was a fatal failure. - * - * '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. - * - * @wpdb object WordPress database object - * - * @return array Array containing status, suggested view, and any data - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - /* - * Run constructor for the Contacts data class - * - * Note, the third parameter is a flag that indicates to the Contacts - * data class that it should flag a group of fields as 'view_only'. - */ -// parent::__construct(false, false, true); - - - } - - public function modelAction($actionData = false) - { - $displayData = 'Hello, World! This is the Social Add-On "social" model talking to you from inside WordPress.'; - $success = true; - $socials = false; - $socialUpdated = false; - $haveMember = false; - $socialError = false; - $newSocial = false; - $option = false; - - $socialArray = array( - 'facebook' => array( - 'name' => 'Facebook', - 'xpos' => -5, - 'ypos' => -5, - 'baseurl' => 'www.facebook.com' - ), - 'twitter' => array( - 'name' => 'Twitter', - 'xpos' => -44, - 'ypos' => -5, - 'baseurl' => 'www.twitter.com' - ), - 'pinterest' => array( - 'name' => 'Pinterest', - 'xpos' => -84, - 'ypos' => -5, - 'baseurl' => 'www.pinterest.com' - ), - 'googleplus' => array( - 'name' => 'Google Plus', - 'xpos' => -124, - 'ypos' => -5, - 'baseurl' => 'www.google.com' - ), - 'digg' => array( - 'name' => 'Digg', - 'xpos' => -163, - 'ypos' => -5, - 'baseurl' => 'www.digg.com' - ), - 'linkedin' => array( - 'name' => 'LinkedIn', - 'xpos' => -203, - 'ypos' => -5, - 'baseurl' => 'www.linkedin.com' - ), - 'instagram' => array( - 'name' => 'Instagram', - 'xpos' => -242, - 'ypos' => -5, - 'baseurl' => 'www.instagram.com' - ), - 'youtube' => array( - 'name' => 'YouTube', - 'xpos' => -322, - 'ypos' => -5, - 'baseurl' => 'www.youtube.com' - ), - 'flickr' => array( - 'name' => 'Flickr', - 'xpos' => -44, - 'ypos' => -44, - 'baseurl' => 'www.flickr.com' - ), - 'blog' => array( - 'name' => 'blog', - 'xpos' => -124, - 'ypos' => -45, - 'baseurl' => '#' - ), - 'photobucket' => array( - 'name' => 'Photobucket', - 'xpos' => -282, - 'ypos' => -45, - 'baseurl' => 'www.photobucket.com' - ), - ); - - // If there's an action option - if (isset($_REQUEST['option'])) { - $option = trim($_REQUEST['option']); - } - - $socialData = $this->editEntry($memberID); - - if (!$socialData) { - $socialData = $this->newEntry($memberID); - $newSocial = true; - - } -// switch($option) { -// case 'update': -// default: -// $this->updateEntry($memberID); -// if ($socialData) { -// $socialUpdated = true; -// } else { -// $socialError = true; -// } -// -// $option = 'update'; -// break; -// } - - $memberID = 0; - if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) { - $memberID = $_REQUEST['member'] - 0; - } - if ($memberID == 0) { - - // There should have been a member ID - So failure - return array( - 'status' => false, - 'menuItemRedirect' => 'error', - 'modelRedirect' => 'index', - 'view' => 'admin/error/index.html', - 'data' => false - ); - - } - -// if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') { - if ($option == 'submit') { - - $socialData = $this->updateEntry($memberID); - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("  Social Update: $memberID", 'Process'); - } - - // If update was successful then use editEntry() to setup for the edit again. - if ($socialData) { - - $socialData = $this->editEntry($memberID); - $socialUpdated = true; - - // Also update all member info records with any possible name change - $sql = " - UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_urls - SET facebook_url = www.testval.com - WHERE member_id = 1 - ;"; -// $sql = " -// UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_urls -// SET facebook_url = '".addslashes($socialData['fieldData']['name'])."' -// WHERE member_id = $memberID -// ;"; - $this->wpdb->query($sql); - - } - } - - // If we had a fatal error, redirect to the error page - if ($socialError) { - return array( - 'status' => $success, - 'option' => $option, - 'menuItemRedirect' => 'error', - 'modelRedirect' => 'index', - 'view' => 'admin/error/index.html', - 'data' => false - ); - } - - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { - glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); - } - - // Compile template data - $templateData = array( - 'displayData' => $displayData, - 'socialArray' => $socialArray, - 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, - 'socials' => $socials, - 'socialUpdated' => $socialUpdated, - 'socialError' => $socialError, - 'haveMember' => $haveMember, - 'memberID' => $memberID, - 'option' => $option - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/social/index.html', - 'data' => $templateData - ); - } -} diff --git a/models/admin/social/more.php b/models/admin/social/more.php deleted file mode 100644 index a94575c..0000000 --- a/models/admin/social/more.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -// Load Contacts data abstract -//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); - -class GlmMembersAdmin_social_more // extends GlmDataContacts -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - /** - * Contact Info - * - * @var $contactInfo - * @access public - */ - public $contactInfo = false; - /** - * Member ID - * - * @var $memberID - * @access public - */ - public $memberID = false; - /** - * Contact ID - * - * @var $contactID - * @access public - */ - public $contactID = false; - - - /* - * Constructor - * - * This contructor performs the work for this model. This model returns - * an array containing the following. - * - * 'status' - * - * True if successfull and false if there was a fatal failure. - * - * '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. - * - * @wpdb object WordPress database object - * - * @return array Array containing status, suggested view, and any data - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - /* - * Run constructor for the Contacts data class - * - * Note, the third parameter is a flag that indicates to the Contacts - * data class that it should flag a group of fields as 'view_only'. - */ -// parent::__construct(false, false, true); - - - } - - public function modelAction($actionData = false) - { - - $displayData = 'Welcome to more information!
This is the Social Add-On "social" model with action "more" talking to you from inside WordPress.'; - $socialArray = array( - 'member1' => array( - 'facebookurl' => 'www.facebook.com', - 'youtubeurl' => 'www.youtube.com', - 'googleurl' => 'www.google.com', - 'gaslighturl' => 'www.gaslightmedia.com' - ), - - 'member2' => array( - 'facebookurl' => 'www.facebook.com', - 'youtubeurl' => 'www.youtube.com', - 'googleurl' => 'www.google.com', - 'gaslighturl' => 'www.gaslightmedia.com' - ), - - 'member2' => array( - 'facebookurl' => 'www.facebook.com', - 'youtubeurl' => 'www.youtube.com', - 'googleurl' => 'www.google.com', - 'gaslighturl' => 'www.gaslightmedia.com' - ) - - ); - // Compile template data - $templateData = array( - 'displayData' => $displayData, - 'socialArray' => $socialArray - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/social/more.html', - 'data' => $templateData - ); - - } - - -} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 90c84c5..7a5e3e2 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -71,30 +71,30 @@ */ // Add a main menu item -add_menu_page( - 'GLM Social', // Page Title - 'GLM Social', // Menu Title - 'glm-members-members', // Capability - 'glm-members-admin-menu-social', // Menu Slug - function() {$this->controller('social');}, // Called function - false, // Icon URL - '92' // Menu Position -); - -add_submenu_page( - 'glm-members-admin-menu-social', // Parent slug - 'Social', // Page title - 'Social', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-social-social', // Menu slug - function() {$this->controller('social');} -); - -add_submenu_page( - 'glm-members-admin-menu-social', // Parent slug - 'Info', // Page title - 'Info', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-social-info', // Menu slug - function() {$this->controller('info');} -); +//add_menu_page( +// 'GLM Social', // Page Title +// 'GLM Social', // Menu Title +// 'glm-members-members', // Capability +// 'glm-members-admin-menu-social', // Menu Slug +// function() {$this->controller('social');}, // Called function +// false, // Icon URL +// '92' // Menu Position +//); +// +//add_submenu_page( +// 'glm-members-admin-menu-social', // Parent slug +// 'Social', // Page title +// 'Social', // Menu Title +// 'glm_members_members', // Capability required +// 'glm-members-admin-menu-social-social', // Menu slug +// function() {$this->controller('social');} +//); +// +//add_submenu_page( +// 'glm-members-admin-menu-social', // Parent slug +// 'Info', // Page title +// 'Info', // Menu Title +// 'glm_members_members', // Capability required +// 'glm-members-admin-menu-social-info', // Menu slug +// function() {$this->controller('info');} +//); diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index 090600e..9912c57 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -11,8 +11,8 @@ -- To permit each query below to be executed separately, -- all queries must be separated by a line with four dashes -CREATE TABLE {prefix}media_urls ( - member_id INT NULL, +CREATE TABLE {prefix}urls ( + id INT NULL, facebook TEXT NULL, twitter TEXT NULL, pinterest TEXT NULL, @@ -25,27 +25,27 @@ CREATE TABLE {prefix}media_urls ( flickr TEXT NULL, blog TEXT NULL, photobucket TEXT NULL, - PRIMARY KEY (member_id), - INDEX(member_id) + PRIMARY KEY (id), + INDEX(id) ); ---- -CREATE TABLE {prefix}media_record ( - social_id INT NOT NULL AUTO_INCREMENT, - social_name TINYTEXT NULL, - social_xpos int NULL, - social_ypos int NULL, - social_baseurl TINYTEXT NULL, +CREATE TABLE {prefix}records ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NULL, + xpos int NULL, + ypos int NULL, + baseurl TINYTEXT NULL, active BOOLEAN NOT NULL DEFAULT '1', - PRIMARY KEY (social_id), - INDEX(social_id) + PRIMARY KEY (id), + INDEX(id) ); ---- -INSERT INTO {prefix}media_record - (social_name, social_xpos, social_ypos, social_baseurl, active) +INSERT INTO {prefix}records + (name, xpos, ypos, baseurl, active) VALUES ('Facebook',-5,-5,'www.facebook.com',true), ('Twitter',-44,-5,'www.twitter.com',true), ('Pinterest',-84,-5,'www.pinterest.com',true), diff --git a/setup/validActions.php b/setup/validActions.php index e8626e8..4d54cde 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -49,13 +49,6 @@ $glmMembersSocialAddOnValidActions = array( 'member' => array( 'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, ), - 'social' => array( - 'index' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, - 'more' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, - ), - 'info' => array( - 'index' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG - ), 'settings' => array( 'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG ) diff --git a/views/admin/info/index.html b/views/admin/info/index.html deleted file mode 100644 index eab9b97..0000000 --- a/views/admin/info/index.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

Info Sub-menu Model

-

{$displayData}

-
-
\ No newline at end of file diff --git a/views/admin/member/social.html b/views/admin/member/social.html index a97192f..9b7e021 100644 --- a/views/admin/member/social.html +++ b/views/admin/member/social.html @@ -3,23 +3,23 @@

Member Social Tab

{$displayData}

- {foreach from=$existingSocials key=k item=socialItem} + {foreach from=$socials key=k item=socialItem} {if $socialItem.active} - {$socialField = $socialItem.social_name|lower} + {$socialField = $socialItem.name|lower} {/if} @@ -30,10 +30,10 @@ - {include file='admin/footer.html'} \ No newline at end of file diff --git a/views/admin/settings/social.html b/views/admin/settings/social.html index a5c662f..0a47b77 100644 --- a/views/admin/settings/social.html +++ b/views/admin/settings/social.html @@ -3,31 +3,31 @@

Member Social Tab

{$displayData}

-
+
- {$socialItem.social_name} + {$socialItem.name}
- +
{foreach from=$existingSocials key=k item=socialItem} - {$socialField = $socialItem.social_name|lower} + {$socialField = $socialItem.name|lower}
- + -
+
- {$socialItem.social_name} + {$socialItem.name}