From cc65ebbdbe97b1fc15584d1e7943cfd42c61a9ab Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Wed, 24 Feb 2016 14:17:37 -0500 Subject: [PATCH] Shows a proper view --- index.php | 2 +- models/admin/member/social.php | 185 +++++++++++++++++- models/admin/social/index.php | 183 ++++++++++++++++- models/admin/social/more.php | 27 ++- .../SOCIAL.create_database_V0.0.1.sql | 66 ------- .../create_database_V0.0.1.sql | 45 +++++ .../{SOCIAL.dbVersions.php => dbVersions.php} | 3 +- views/admin/error/badAction.html | 11 ++ views/admin/error/header.html | 5 + views/admin/error/index.html | 12 ++ views/admin/member/social.html | 50 ++--- views/admin/social/index.html | 21 ++ 12 files changed, 502 insertions(+), 108 deletions(-) delete mode 100644 setup/databaseScripts/SOCIAL.create_database_V0.0.1.sql create mode 100644 setup/databaseScripts/create_database_V0.0.1.sql rename setup/databaseScripts/{SOCIAL.dbVersions.php => dbVersions.php} (95%) create mode 100644 views/admin/error/badAction.html create mode 100644 views/admin/error/header.html create mode 100644 views/admin/error/index.html diff --git a/index.php b/index.php index e9d8a08..d003341 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,7 @@ * version from this plugin. */ define('GLM_MEMBERS_SOCIAL_PLUGIN_VERSION', '0.0.6'); -// define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.1'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_SOCIAL_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.57'); diff --git a/models/admin/member/social.php b/models/admin/member/social.php index f3d5f11..eb712d7 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_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); +require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocial.php'); -class GlmMembersAdmin_member_social // extends GlmDataContacts +class GlmMembersAdmin_member_social extends GlmDataSocial { /** @@ -103,16 +103,187 @@ class GlmMembersAdmin_member_social // extends GlmDataContacts 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'); + } - $displayData = 'This is the Social "Member" "Social" model talking to you from inside WordPress.'; + // 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."socialURL + SET facebook_url = www.testval.com + WHERE member_id = 1 + ;"; +// $sql = " +// UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."socialURL +// 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, - 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL - + '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, @@ -120,7 +291,5 @@ class GlmMembersAdmin_member_social // extends GlmDataContacts 'view' => 'admin/member/social.html', 'data' => $templateData ); - } - } diff --git a/models/admin/social/index.php b/models/admin/social/index.php index 8899c8e..de6e9d5 100644 --- a/models/admin/social/index.php +++ b/models/admin/social/index.php @@ -16,6 +16,9 @@ // Load Contacts data abstract //require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); + + + class GlmMembersAdmin_social_index // extends GlmDataContacts { @@ -103,12 +106,185 @@ class GlmMembersAdmin_social_index // extends GlmDataContacts 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."socialURL + SET facebook_url = www.testval.com + WHERE member_id = 1 + ;"; +// $sql = " +// UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."socialURL +// 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 + '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 @@ -118,8 +294,5 @@ class GlmMembersAdmin_social_index // extends GlmDataContacts 'view' => 'admin/social/index.html', 'data' => $templateData ); - } - - } diff --git a/models/admin/social/more.php b/models/admin/social/more.php index 2cd5d0e..a94575c 100644 --- a/models/admin/social/more.php +++ b/models/admin/social/more.php @@ -105,10 +105,33 @@ class GlmMembersAdmin_social_more // extends GlmDataContacts { $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 + 'displayData' => $displayData, + 'socialArray' => $socialArray ); // Return status, any suggested view, and any data to controller diff --git a/setup/databaseScripts/SOCIAL.create_database_V0.0.1.sql b/setup/databaseScripts/SOCIAL.create_database_V0.0.1.sql deleted file mode 100644 index dad54d8..0000000 --- a/setup/databaseScripts/SOCIAL.create_database_V0.0.1.sql +++ /dev/null @@ -1,66 +0,0 @@ --- Gaslight Media Members Database - Social --- File Created: 12/02/15 15:27:15 --- Database Version: 0.0.1 --- Database Creation Script --- --- This file is called to create a new set of tables for this --- add-on for the most receint database version for this add-on. --- --- There should only be one such file in this directory --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes - - --- Social Management Settings -CREATE TABLE {prefix}management ( - id INT NOT NULL AUTO_INCREMENT, - canonical_social_page TINYTEXT NULL, -- Canonical page slug for detail - PRIMARY KEY (id) -); - ----- - --- Set default social management entry -INSERT INTO {prefix}management - ( id, canonical_social_page ) - VALUES - ( 1, 'social data' ) -; - ----- - -CREATE TABLE {prefix}social ( - id INT NOT NULL AUTO_INCREMENT, - blogger_url TEXT NULL, - youtube_url TEXT NULL, - facebook_url TEXT NULL, - twitter_url TEXT NULL, - imgur_url TEXT NULL, - flickr_url TEXT NULL, - tumblr_url TEXT NULL, - instagram_url TEXT NULL, - linkedin_url TEXT NULL, - googleplus_url TEXT NULL, - PRIMARY KEY (id) -); - ----- - -CREATE TABLE {prefix}SOCIALTEST ( - id INT NOT NULL AUTO_INCREMENT, - active BOOLEAN NULL, -- Package is active - title TINYTEXT NULL, -- Title of package - package_slug TINYTEXT NULL, -- Package name slug for canonical URLs (lowercase, "-" for spaces, no punctuation) - descr TEXT NULL, -- Description of package - short_descr TINYTEXT NULL, -- Short description of package - image TINYTEXT NULL, -- Package image - start_date TIMESTAMP NULL, -- Date display of this package starts - end_date TIMESTAMP NULL, -- Date display of this package ends (last date of display) - expire_date TIMESTAMP NULL, -- Date package expires (first date it's expired) - position INT NULL, -- Display order position - pricing TINYTEXT NULL, -- Pricing, descriptive - ref_type INT NULL, -- Type of entity this package is associated with - ref_dest INT NULL, -- Pointer to the specific entity - PRIMARY KEY (id), -); diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql new file mode 100644 index 0000000..a91530c --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -0,0 +1,45 @@ +-- Gaslight Media Members Database - Social +-- File Created: 12/02/15 15:27:15 +-- Database Version: 0.0.1 +-- Database Creation Script +-- +-- This file is called to create a new set of tables for this +-- add-on for the most recent database version for this add-on. +-- +-- There should only be one such file in this directory +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +CREATE TABLE {prefix}socialURL ( + member_id INT NULL, + facebook_url TEXT NULL, + twitter_url TEXT NULL, + pinterest_url TEXT NULL, + googleplus_url TEXT NULL, + digg_url TEXT NULL, + linkedin_url TEXT NULL, + instagram_url TEXT NULL, + rss_url TEXT NULL, + youtube_url TEXT NULL, + flickr_url TEXT NULL, + blog_url TEXT NULL, + photobucket_url TEXT NULL + PRIMARY KEY (member_id), + INDEX(member_id) +); + +---- + +CREATE TABLE {prefix}socialMEDIA ( + id INT NOT NULL AUTO_INCREMENT, + social_name TINYTEXT NULL, + social_xpos int NULL, + social_ypos int NULL, + social_baseurl TINYTEXT NULL, + PRIMARY KEY (id) +); + +---- + +INSERT INTO \ No newline at end of file diff --git a/setup/databaseScripts/SOCIAL.dbVersions.php b/setup/databaseScripts/dbVersions.php similarity index 95% rename from setup/databaseScripts/SOCIAL.dbVersions.php rename to setup/databaseScripts/dbVersions.php index 1e8be37..1b2aa23 100644 --- a/setup/databaseScripts/SOCIAL.dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -34,6 +34,5 @@ $glmMembersSocialDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 3) + '0.0.1' => array('version' => '0.0.1', 'tables' => 1) ); - diff --git a/views/admin/error/badAction.html b/views/admin/error/badAction.html new file mode 100644 index 0000000..a203586 --- /dev/null +++ b/views/admin/error/badAction.html @@ -0,0 +1,11 @@ +{include file='admin/error/header.html'} + +

Sorry, we've had an error.

+ +

Error: : An invalid action has been specified.

+ + {if $errorMsg}

{$errorMsg}

{/if} + +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +{include file='admin/footer.html'} diff --git a/views/admin/error/header.html b/views/admin/error/header.html new file mode 100644 index 0000000..f9fdb91 --- /dev/null +++ b/views/admin/error/header.html @@ -0,0 +1,5 @@ +
+ +

{$glmPluginName}

+ + \ No newline at end of file diff --git a/views/admin/error/index.html b/views/admin/error/index.html new file mode 100644 index 0000000..02945e3 --- /dev/null +++ b/views/admin/error/index.html @@ -0,0 +1,12 @@ +{include file='admin/error/header.html'} + +
+ +

Sorry, we've had some type of fatal error.

+ +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +
+ +{include file='admin/footer.html'} + diff --git a/views/admin/member/social.html b/views/admin/member/social.html index 5f99600..27ee18e 100644 --- a/views/admin/member/social.html +++ b/views/admin/member/social.html @@ -3,28 +3,30 @@

Members Social Tab

{$displayData}

- - - - - - - - - - - - - - - - - - - -
Facebook
Twitter
Pinterest
Google Plus
Digg
LinkedIn
Instagram
RSS
YouTube
Wordpress
Flickr
Pinterest2
Blog
Wordpress2
?name?
?name?
Photobucket
Blog2
+
+
+

Social Model

+

{$displayData}

+ Click me to see more! +
+ +
Update
+ + {foreach from=$socialArray key=k item=socialItem} + + + + + {/foreach} +
+
+
+ {$socialItem.name} +
+ +
+ +
+
+
{include file='admin/footer.html'} \ No newline at end of file diff --git a/views/admin/social/index.html b/views/admin/social/index.html index 665f0f3..244479e 100644 --- a/views/admin/social/index.html +++ b/views/admin/social/index.html @@ -3,5 +3,26 @@

Social Model

{$displayData}

Click me to see more! + +
+ +
Update
+ + {foreach from=$socialArray key=k item=socialItem} + + + + + {/foreach} +
+
+
+ {$socialItem.name} +
+ +
+ +
+
\ No newline at end of file -- 2.17.1