From d7e6bccd2af77d282a266f827a77d55c4d0bbc3c Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 16 May 2016 16:09:51 -0400 Subject: [PATCH] Completed social media management fucntions --- classes/data/dataSocialUrls.php | 41 +++++-- classes/data/dataSocials.php | 3 +- models/admin/management/social.php | 39 ++++-- views/admin/management/social.html | 184 ++++++++++++++++++++++++----- 4 files changed, 219 insertions(+), 48 deletions(-) diff --git a/classes/data/dataSocialUrls.php b/classes/data/dataSocialUrls.php index 3ccafe0..ead910d 100644 --- a/classes/data/dataSocialUrls.php +++ b/classes/data/dataSocialUrls.php @@ -136,6 +136,14 @@ class GlmDataSocialUrls extends GlmDataAbstract 'use' => 'a' ), + // Social Media Type ID + 'social' => array( + 'field' => 'social', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + // Reference Type - Insert new record 'ref_type_insert' => array ( 'field' => 'ref_type', @@ -170,24 +178,43 @@ class GlmDataSocialUrls extends GlmDataAbstract 'use' => 'ilged' ), - // The member's URL for a certain medium 'url' => array ( 'field' => 'url', 'type' => 'text', - 'default' => true, 'use' => 'a' ), - // The social medium - 'social' => array ( + + // The social media active + 'social_active' => array ( 'field' => 'social', + 'as' => 'social_active', 'type' => 'pointer', 'p_table' => GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socials', 'p_field' => 'name', - 'p_orderby' => 'name', - 'p_blank' => true, - 'use' => 'a' + 'use' => 'gl' + ), + + // The social media name + 'social_name' => array ( + 'field' => 'social', + 'as' => 'social_name', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socials', + 'p_field' => 'name', + 'use' => 'gl' + ), + + // The social medium + 'social_b64icon' => array ( + 'field' => 'social', + 'as' => 'social_b64icon', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socials', + 'p_field' => 'b64icon', + 'use' => 'gl' ) + ); } diff --git a/classes/data/dataSocials.php b/classes/data/dataSocials.php index 49276b4..f78a844 100644 --- a/classes/data/dataSocials.php +++ b/classes/data/dataSocials.php @@ -133,8 +133,7 @@ class GlmDataSocials extends GlmDataAbstract // Base 64 Image Icon 'b64icon' => array ( 'field' => 'b64icon', - 'type' => 'integer', - 'view_only' => true, + 'type' => 'b64image', 'use' => 'a' ), diff --git a/models/admin/management/social.php b/models/admin/management/social.php index 1c6b07f..494a23f 100644 --- a/models/admin/management/social.php +++ b/models/admin/management/social.php @@ -86,23 +86,40 @@ class GlmMembersAdmin_management_social extends GlmDataSocials $socialError = false; $statusMessage = 'Social Updated'; $option = false; + $socialID = false; $debug = true; - $socialList = $this->getList(); - + // Check for specified option if (isset($_REQUEST['option'])) { $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); - } else { - $option = "default"; + } + + // Check for specified ID + if (isset($_REQUEST['id'])) { + $socialID = ($_REQUEST['id'] - 0); } switch ($option) { - case "submit": - $Socials->updateEntry(); + + case "addNew"; + $this->insertEntry(); +// **** NEED TO ADD TO ALL MEMBERS ALSO break; - case "social"; - default: + case "update": + $this->updateEntry($socialID); + break; + + case "delete"; + $this->deleteEntry($socialID, true); + // Also delete all uses of this social media type + $this->wpdb->query(" + DELETE FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . "social_urls + WHERE social = $socialID; + "); + break; + + default: break; } @@ -118,10 +135,8 @@ class GlmMembersAdmin_management_social extends GlmDataSocials ); } -// if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { -// glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); -// } - // Refresh the URL list before sending it to the front + // Get a list of all social media types + $socialList = $this->getList(); // Compile template data $templateData = array( diff --git a/views/admin/management/social.html b/views/admin/management/social.html index 5b5baa7..3669e03 100644 --- a/views/admin/management/social.html +++ b/views/admin/management/social.html @@ -2,54 +2,184 @@

{if $socialUpdated}{$statusMessage}{/if}

+ +
Add a Social Media Type
+
+
+ + + + + + + + + + + + + + + + + + + +
Name: + +
Active:
Base URL: + +
Icon
+

* Required

+ +
+
+ + +
+
+

Are you sure you want to delete this social media type?

+

Yes, delete this social media type

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + +
Name: + +
Active: + +
Base URL: + +
Icon
+

* Required

+ +
+
+

Social Media Types

- - +
ActiveNameImage
+ + + + + + + {foreach $socials as $s} + - - - - - {/foreach}
NameActiveImageBase URL 
+ {$s.name} + {$s.active.name} -
-
+ {if $s.b64icon} + Embedded Image + {else} + (no image) + {/if}
- {$socialItem.name} + + {$s.baseurl} -
- -
- +
Delete
-
-
-
-
-
New image:
-
- {include file='admin/footer.html'} -- 2.17.1